How can I get a backtrace on segfault?

Jonathan M Davis jmdavisProg at gmx.com
Wed Sep 14 02:47:25 PDT 2011


On Wednesday, September 14, 2011 10:38:38 Tobias Pankrath wrote:
> > What OS are you on? On 32-bit Linux, it should just work. On 64-bit
> 
> Linux,
> 
> > there's a bug which makes it so that you don't get one. If you're on
> > Windows (which I'm guessing that you're not since you're talking about
> > segfaults rather than access violations), then I believe that it should
> > just work, but there might be something that you have to do to get it
> 
> to
> 
> > work (I don't use Windows much, so I'm not sure).
> > 
> > - Jonathan M Davis
> 
> 64 bit linux :-(. Thank you for your fast response.

Actually. wait. I wasn't thinking right. You never get a backtrace from a 
segfault. There _is_ a bug on 64-bit Linux which makes it so that backtraces 
don't work, but you don't get a stacktrace from a segfault regardless. The way 
to handle that is to get a core dump and use gdb on it. However, 
unfortunately, 64-bit programs generated by dmd don't seem to be work with gdb 
(though 32-bit programs will). It's a result of the fact that 64-bit support 
for dmd is pretty new. Still, they're annoying bugs.

In any case, the best way to handle your problem would probably be to compile 
your program as 32-bit, run it with core dumps enabled, and use gdb on it. 
That should show you where the problem is unless the segfault is 64-bit 
specific for some reason.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list