[wxPython] Could "Segmentation faults" be turned to "Tracebacks" ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Could "Segmentation faults" be turned to "Tracebacks" ?

Nicolas Chauvat-2
Hi,

I'm currently developping a gui with wxpython. As it often happens during
development, I make mistakes (I try not to, but... :-). My problem is that
instead of the usual nice Python traceback that tells you where and why
the program crashed, I keep getting segmentation faults and coredumps,
which are much harder to debug.

My understanding is that this has to do with the fact that python uses the
underlying C++ libraries and doesn't (can't?) trap those segfaults then
raise an exception. In some cases at least you'll get exceptions: if you
use an argument of the wrong type for example (but maybe this test is
added during the wrapping process by SWIG when preparing/compiling the
wx* modules ?).

It would be so useful not to have to fall back to print statements to find
out where the error exactly occured (sure, I can recompile everything with
debugging turned on and trace it or use gdb on the core, but one of the
reasons I'm using python is that I want to benefit from the interpreted
aspect of the language).

For what I remember, when using tkinter, you would get back a traceback on
errors, eventually printing the Tcl errors (but Tcl is a scripting
language that can print tracebacks, so that's probably the reason).

Could something be done at the python/binaries interface so that it would
at least print the line where it happened ?

I'm almost certain the answer is no, but maybe someone will have an
idea :-)

-- Nicolas

 (o-  Hi, I'm a deadly e-mail virus, please copy me into your .signature
 /\   file to help me spread. :: Bonjour, je suis un dangereux virus. SVP
Y_/_  copiez-moi dans votre fichier .signature pour m'aider à me propager.    


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Could "Segmentation faults" be turned to "Tracebacks" ?

Gregory Landrum
At 05:49 PM 2/16/00 -0800, Nicolas Chauvat wrote:

>Hi,
>
>I'm currently developping a gui with wxpython. As it often happens during
>development, I make mistakes (I try not to, but... :-). My problem is that
>instead of the usual nice Python traceback that tells you where and why
>the program crashed, I keep getting segmentation faults and coredumps,
>which are much harder to debug.
>
>My understanding is that this has to do with the fact that python uses the
>underlying C++ libraries and doesn't (can't?) trap those segfaults then
>raise an exception. In some cases at least you'll get exceptions: if you
>use an argument of the wrong type for example (but maybe this test is
>added during the wrapping process by SWIG when preparing/compiling the
>wx* modules ?).
>
>It would be so useful not to have to fall back to print statements to find
>out where the error exactly occured (sure, I can recompile everything with
>debugging turned on and trace it or use gdb on the core, but one of the
>reasons I'm using python is that I want to benefit from the interpreted
>aspect of the language).
>
>For what I remember, when using tkinter, you would get back a traceback on
>errors, eventually printing the Tcl errors (but Tcl is a scripting
>language that can print tracebacks, so that's probably the reason).
>
>Could something be done at the python/binaries interface so that it would
>at least print the line where it happened ?
>
>I'm almost certain the answer is no, but maybe someone will have an
>idea :-)
>
>-- Nicolas
>
> (o-  Hi, I'm a deadly e-mail virus, please copy me into your .signature
> /\   file to help me spread. :: Bonjour, je suis un dangereux virus. SVP
>Y_/_  copiez-moi dans votre fichier .signature pour m'aider à me propager .
   
>
>
>_______________________________________________
>wxPython-users maillist  -  [hidden email]
>http://starship.python.net/mailman/listinfo/wxpython-users
>

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Could "Segmentation faults" be turned to "Tracebacks" ?

Gregory Landrum

uh, sorry about that... I (obviously) clicked the wrong button
when trying to cancel that one.

-greg

----
Greg Landrum, Ph.D.              [hidden email]
Sr. Research Scientist      Dupont Pharmaceutical Research Lab
  These are my views, not necessarily those of my employer.

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Could "Segmentation faults" be turned to "Tracebacks" ?

Robin Dunn
In reply to this post by Nicolas Chauvat-2
> Could something be done at the python/binaries interface so that it would
> at least print the line where it happened ?

If you build your own wxWindows and wxPython then you can enable debug mode,
in which case a lot of assertions are compiled into the code and you will get
popup message boxes for things that wxWindows can detect are wrong.

As far as I know there is no way at the C level to trap segfaults and the
various other hairy beasties and gracefully recover, unless you create a
debugger and single step all the code.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!




_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users