473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 2270
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.