472,958 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

A QFB agent: how to catch C-level crashes and last Python stack ?

When employing complex UI libs (wx, win32ui, ..) and other extension
libs, nice "only Python stack traces" remain a myth.

Currently I'm hunting again a rare C-level crash bug of a Python based
Windows app with rare user reports - and still in the dark (I get
snippets of machine stack traces / screenshots with random "mem. access
error" / "python caused the runtime to terminate in an unusual way" / ..)

I'd like to hook a kind of quality feedback agent a C-level to enable
the user transfer a report (similar to what Mozilla/Netscape has), e.g.
in a changed python.exe stub. Next to the machine stack/regs it should
grab the relevant last Python thread stack(s), if any, and maybe other
useful status and python global vars.
(There are also Python threads going on. )

Is that possible?

-robert
Apr 25 '06 #1
2 2242
robert wrote:
When employing complex UI libs (wx, win32ui, ..) and other extension
libs, nice "only Python stack traces" remain a myth.

Currently I'm hunting again a rare C-level crash bug of a Python based
Windows app with rare user reports - and still in the dark (I get
snippets of machine stack traces / screenshots with random "mem. access
error" / "python caused the runtime to terminate in an unusual way" / ..)

I'd like to hook a kind of quality feedback agent a C-level to enable
the user transfer a report (similar to what Mozilla/Netscape has), e.g.
in a changed python.exe stub. Next to the machine stack/regs it should
grab the relevant last Python thread stack(s), if any, and maybe other
useful status and python global vars.
(There are also Python threads going on. )

Is that possible?

-robert


It looks like this may be what you want. Quoting from

http://www.usenix.org/events/usenix0...ey/beazley.pdf

"""
In recent years, scripting languages such as Perl,
Python, and Tcl have become popular development tools
for the creation of sophisticated application software.
One of the most useful features of these languages is
their ability to easily interact with compiled languages
such as C and C++. Although this mixed language approach
has many benefits, one of the greatest drawbacks
is the complexity of debugging that results from using
interpreted and compiled code in the same application.
In part, this is due to the fact that scripting language
interpreters are unable to recover from catastrophic errors
in compiled extension code. Moreover, traditional
C/C++ debuggers do not provide a satisfactory degree
of integration with interpreted languages. This paper
describes an experimental system in which fatal extension
errors such as segmentation faults, bus errors, and
failed assertions are handled as scripting language exceptions.
This system, which has been implemented as
a general purpose shared library, requires no modifications
to the target scripting language, introduces no performance
penalty, and simplifies the debugging of mixed
interpreted-compiled application software.
"""

It may be an interesting project to port this to Windows.

Hope that helps,

Thomas

Apr 27 '06 #2
Thomas Heller wrote:
robert wrote:
When employing complex UI libs (wx, win32ui, ..) and other extension
libs, nice "only Python stack traces" remain a myth.

Currently I'm hunting again a rare C-level crash bug of a Python based
Windows app with rare user reports - and still in the dark (I get
snippets of machine stack traces / screenshots with random "mem.
access error" / "python caused the runtime to terminate in an unusual
way" / ..)

I'd like to hook a kind of quality feedback agent a C-level to enable
the user transfer a report (similar to what Mozilla/Netscape has),
e.g. in a changed python.exe stub. Next to the machine stack/regs it
should grab the relevant last Python thread stack(s), if any, and
maybe other useful status and python global vars.
(There are also Python threads going on. )

Is that possible?

-robert

It looks like this may be what you want. Quoting from

http://www.usenix.org/events/usenix0...ey/beazley.pdf

"""
In recent years, scripting languages such as Perl,
Python, and Tcl have become popular development tools
for the creation of sophisticated application software.
One of the most useful features of these languages is
their ability to easily interact with compiled languages
such as C and C++. Although this mixed language approach
has many benefits, one of the greatest drawbacks
is the complexity of debugging that results from using
interpreted and compiled code in the same application.
In part, this is due to the fact that scripting language
interpreters are unable to recover from catastrophic errors
in compiled extension code. Moreover, traditional
C/C++ debuggers do not provide a satisfactory degree
of integration with interpreted languages. This paper
describes an experimental system in which fatal extension
errors such as segmentation faults, bus errors, and
failed assertions are handled as scripting language exceptions.
This system, which has been implemented as
a general purpose shared library, requires no modifications
to the target scripting language, introduces no performance
penalty, and simplifies the debugging of mixed
interpreted-compiled application software.
"""

It may be an interesting project to port this to Windows.

Hope that helps,


Thanks, exactly. That would be quite luxurious as WAD manages to even
continue normal Python execution on the current stack (only in a UNIX
main thread?) with a regular Python exception. That would make pets out
of all bugs - preventing users from facing nameless app freezes, but
make the help bug elimination for distributed programs by detailed reports.

simply catching signal.SIGSEGV with Python's signal module causes just
looping at 100% CPU load (The GIL is not forced ?)

WAD obviously has not anymore evolved since the beginning.

The Author says, that a Windows port would be quite complex - because
advanced execution context manipulation is obviously not possible with
signals on Windows.
Yet he mentions the Windows C++ "structured exception handling", which
may enable that.

I know that the fast Object Store OO-Database uses exactly that method
to catch and recover execution from seg faults, while updating a kind of
memory mapped database into the system.
I integrated that OO-DBMS exception handler once with Python some years
back by making a C++ file out of python.c as shown below or even by
using that PSECall alone, which is needed anyway for wrapping any other
Python threads (start functions) with the seg fault handler. Probably
there is even better thread control possible than on Linux. Yet I don't
know so far if its possible to find the valid Python exit functions on
the stack (for returning from exceptions) the same style as in Unix ELF
binaries ...

--

#define OS_PSE_ESTABLISH_FAULT_HANDLER \
{ try { _PSE_NS_ _ODI_fault_handler _ODI_handler; try {
...
#define OS_PSE_END_FAULT_HANDLER \
} catch (_PSE_NS_ os_err& e) { e.print(); } \
} catch (_PSE_NS_ _ODI_fault_handler&) {} }
...
#include <os_pse/ostore.hh>
#include "Python.h"

extern "C" { DL_EXPORT(int) Py_Main(int, char**);}

int main(int argc, char **argv)
{
int result=0;

// The top of the stack of every thread of every program
// must be wrapped in a fault handler
// This macro begins the handler's scope
OS_PSE_ESTABLISH_FAULT_HANDLER

result = Py_Main(argc, argv);

// This macro ends the fault handler's scope
OS_PSE_END_FAULT_HANDLER

return result;
}

---
#ifdef SWIG

//# for wrapping python threads with the PSE fault handler
%native(PSECall) _wrap_PSECall;
%{
//#include <os_pse/ostore.hh>
//#include "Python.h"
static PyObject *_wrap_PSECall(PyObject *self, PyObject *args) {
PyObject * func =0 ;
PyObject * funcargs =0 ;

PyObject* result;

if(!PyArg_ParseTuple(args,"OO:PSECall",&func, &funcargs)) return NULL;

// The top of the stack of every thread of every program
// must be wrapped in a fault handler
// This macro begins the handler's scope
OS_PSE_ESTABLISH_FAULT_HANDLER
result = PyEval_CallObject(func,funcargs); // Call Python

// This macro ends the fault handler's scope
OS_PSE_END_FAULT_HANDLER

return result;
}
%}
#endif // SWIG

---
-robert
Apr 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Fuzzyman | last post by:
I'm writing a function that will query the comp.lang.python newsgroup via google groups....... (I haven't got nntp access from work..) I'm using urllib (for the first time)..... and google don't...
5
by: Matt | last post by:
Hello I am running a SP from the SQL Server Agent, the job has one step that looks like this. exec q_spr_inlevextsystem This job fails with the following message Job 'AutoInlev' : Step...
60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
6
by: Marvin Libson | last post by:
Hi All: I am running DB2 UDB V7.2 with FP11. Platform is Windows 2000. I have created a java UDF and trigger. When I update my database I get the following error: SQL1224N A database...
1
by: Jon Spivey | last post by:
Hi, I'm using webrequest to scrape some urls, works fine, however one url seems to be throwing an error when it doesn't recognise the user agent. So I need to set the user agent to something...
1
by: FreeXenon | last post by:
OK, I am having a lot of problems loading an XML file via a Server-Side JavaScript based ASP page. Below is the code that I am using as well as the different methods of loading the XML file and the...
0
by: =?Utf-8?B?TWlrZTEz?= | last post by:
Sorry for the cross post from dontnet.framework but I'm hoping this may see more activity here. I have written an application to access a web service. The application runs at multiple sites and...
0
by: =?Utf-8?B?TWlrZTEz?= | last post by:
Sorry for the cross post; I'm hoping this will get a response here... I have written an application to access a web service. The application runs at multiple sites and must cross a proxy server....
35
by: RobG | last post by:
Seems developers of mobile applications are pretty much devoted to UA sniffing: <URL: http://wurfl.sourceforge.net/vodafonerant/index.htm > -- Rob
5
by: Gordon | last post by:
As part of a data collecting system (basically a system that collects submissions from forms), I was planning on logging a bit of data about the submitting user agent for the purposes of spotting...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.