Getting Stack Trace on segfault

J

James Stroud

Hello All,

The built-in mac osx vecLib is segfaulting in some cases--A very fun
fact to find out the hard way over two nights of work. I also spent an
embarrassing amount of time figuring out just where. Although I'm in
quite a self-congratulatory mood right now, in the future, I feel like I
could save a lot of time by coercing the interpreter to spew forth
method calls to stderr. Is this possible?


I would hope to produce something hauntingly reminiscent of

[] my_function
[my_function] another_function
[my_function -> another_function] yet_a_deeper_function


Presentation, of course, is irrelevant.


I read the docs on pdb, but it did not seem to do what I want--unless,
of course, I missed something.


James
 
K

kyosohma

Hello All,

The built-in mac osx vecLib is segfaulting in some cases--A very fun
fact to find out the hard way over two nights of work. I also spent an
embarrassing amount of time figuring out just where. Although I'm in
quite a self-congratulatory mood right now, in the future, I feel like I
could save a lot of time by coercing the interpreter to spew forth
method calls to stderr. Is this possible?

I would hope to produce something hauntingly reminiscent of

[] my_function
[my_function] another_function
[my_function -> another_function] yet_a_deeper_function

Presentation, of course, is irrelevant.

I read the docs on pdb, but it did not seem to do what I want--unless,
of course, I missed something.

James

Hi,

I've never done that before, but I found a recipe that claims to do it
with meta-classes. Check it out:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/198078

I hope this gives you some ideas.

Mike
 
R

rocky.bernstein

Hello All,

The built-in mac osx vecLib is segfaulting in some cases--A very fun
fact to find out the hard way over two nights of work. I also spent an
embarrassing amount of time figuring out just where. Although I'm in
quite a self-congratulatory mood right now, in the future, I feel like I
could save a lot of time by coercing the interpreter to spew forth
method calls to stderr. Is this possible?

I would hope to produce something hauntingly reminiscent of

[] my_function
[my_function] another_function
[my_function -> another_function] yet_a_deeper_function

Presentation, of course, is irrelevant.

I read the docs onpdb, but it did not seem to do what I want--unless,
of course, I missed something.

James

pydb (http://bashdb.sf.net0 has the ability to do noninteractive line
tracing. See http://bashdb.sourceforge.net/pydb/pydb/lib/subsubsection-set.html
or the showmedo demo. It would be kind of neat to extend this to allow
for method/fn tracing. Alas the simple hack I tried, didn't work
because of code obscurities. (The code could stand to use a rewrite.)
 
R

rocky.bernstein

After a night's rest, I was able to add a function trace to pydb,
command option --fntrace, short option -F, and set/show command
"fntrace".

It's still a little bit funky. (Hey, I didn't get *that* good of a
rest). But it's out there in pydb's CVS in case folks want to try it.

Also, following an idea given in the recipe, I've extended the 'Call'
and 'Return' indicators so that we list the current stack level. For
"Return" we'll also list the return value (or at least a repr() of it
for strings and scalars) and/or return type. What's a little odd here
is that levels from the debugger are included in the nesting count. So
the top-level in the user program will be greater than 1.

It's possible there will be another release around the time of the
next ipython release since there is better coordination between the
two with respect to colorizing lines of code.

Hello All,
The built-in mac osx vecLib is segfaulting in some cases--A very fun
fact to find out the hard way over two nights of work. I also spent an
embarrassing amount of time figuring out just where. Although I'm in
quite a self-congratulatory mood right now, in the future, I feel like I
could save a lot of time by coercing the interpreter to spew forth
method calls to stderr. Is this possible?
I would hope to produce something hauntingly reminiscent of
[] my_function
[my_function] another_function
[my_function -> another_function] yet_a_deeper_function
Presentation, of course, is irrelevant.
I read the docs onpdb, but it did not seem to do what I want--unless,
of course, I missed something.

pydb (http://bashdb.sf.net0has the ability to do noninteractive line
tracing. Seehttp://bashdb.sourceforge.net/pydb/pydb/lib/subsubsection-set.html
or the showmedo demo. It would be kind of neat to extend this to allow
for method/fn tracing. Alas the simple hack I tried, didn't work
because of code obscurities. (The code could stand to use a rewrite.)
 
J

John J. Lee

James Stroud said:
Hello All,

The built-in mac osx vecLib is segfaulting in some cases--A very fun
fact to find out the hard way over two nights of work. I also spent an
embarrassing amount of time figuring out just where. Although I'm in
quite a self-congratulatory mood right now, in the future, I feel like
I could save a lot of time by coercing the interpreter to spew forth
method calls to stderr. Is this possible?


I would hope to produce something hauntingly reminiscent of

[] my_function
[my_function] another_function
[my_function -> another_function] yet_a_deeper_function
[...]

I remember David Beazley (of SWIG fame) wrote something called WAD
that claimed to turn segfaults into Python exceptions (hence
tracebacks). IIRC it was Linux-specific, and I have no idea how it
worked. I guess it could be ported to Windows with SEH, but no idea
about OS X.


John
 
B

bernhard.voigt

GDB would could work. Here's how I use it to track down problems in a C
++ program controlled by python.

$ gdb python
GDB starts up, now at the gdb prompt, set the program args

(gdb) set arg testscript.py
(gdb) run
.... program running until crash
(gdb) where
gives you the backtrace if you compiled you're module code with debug
options

Cheers! Bernhard


James Stroud said:
Hello All,
The built-in mac osx vecLib is segfaulting in some cases--A very fun
fact to find out the hard way over two nights of work. I also spent an
embarrassing amount of time figuring out just where. Although I'm in
quite a self-congratulatory mood right now, in the future, I feel like
I could save a lot of time by coercing the interpreter to spew forth
method calls to stderr. Is this possible?
I would hope to produce something hauntingly reminiscent of
[] my_function
[my_function] another_function
[my_function -> another_function] yet_a_deeper_function

[...]

I remember David Beazley (of SWIG fame) wrote something called WAD
that claimed to turn segfaults into Python exceptions (hence
tracebacks). IIRC it was Linux-specific, and I have no idea how it
worked. I guess it could be ported to Windows with SEH, but no idea
about OS X.

John
 

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top