From: barabba Date: 2007-04-12T09:10:05+09:00 Subject: Re: Ruby C extension crash: how to create a stack trace? On Apr 10, 10:15 pm, Paul Brannan wrote: > On Wed, Apr 11, 2007 at 04:25:11AM +0900, barabba wrote: > > Yes it is fast the same. MSVC start and run ruby using my_script.rb as > > argument. The problem is the "backtrace", it is only one line, because > > ruby don't crash, just exit. > > Gdb stops when the application gets a signal, rather than waiting for > the application to terminate. > > > It is still not clear why > > trap("SEGV"){"my seg fault handler";exit} > > doesn't work on my system. It seam that the exception is caught, but > > the C code is recalled at the same place where the error is generated > > causing an infinite loop (may be an EXCEPTION_CONTINUE_EXECUTION is > > used in the trap handler?). > > If you segfault, you have already entered into the world of undefined > behavior. Anything your application does after that point is > unpredictable. > > (For that reason, in most applications it's better to let the > application crash than to continue running in a bad state). > > Do you get a stack trace if you place a breakpoint in sighandler() (in > signal.c)? > > Paul I have built a debug version of ruby 1.8.6 under windows with msvc6. A breakpoint in sighandler() is not reached. I have set also a breakpoint in sigsegv(sig) This is the stack trace when the extension crash and reach the breakpoint: sigsegv(int 11) line 622 MSVCRT! 77c32efa() RUBY! mainCRTStartup + 257 bytes KERNEL32! 7c816d4f() This say nothing where my extension crash, but maybe it is possible to get more information using win32 GetExceptionInformation(). Not really comfortable. May be it is better the possibility to turn off SEH inside ruby and leave this to visual studio. But I haven't found in ruby source how SEH are turned on.