How can I get a backtrace on segfault?
Jonathan M Davis
jmdavisProg at gmx.com
Wed Sep 14 03:08:32 PDT 2011
On Wednesday, September 14, 2011 11:55:48 Alex Rønne Petersen wrote:
> As an aside, I still think DMD needs an option to insert null checks
> everywhere, at least for debugging...
That would fix only a portion of segfaults, so as far as the general segfaults
go, that's not a complete solution. Regardless of that however, Walter is
dead-set against adding null checks, because his take on it is that the OS
does them already (hence the segfault) and that you can always get the
backtrace (along with other useful information) by using a debugger, so he's
not going to add null checks.
Now, I do agree that it would be nice to have them for debugging purposes, but
it's just not going to happen. Walter is too opinionated on the issue.
The way to get stacktraces for all segfaults is to add a handler for SIGSEV
which prints a backtrace. And arguably, it's a better solution than doing null
checks anyway, because it gives you a stacktrace without the extra overhead of
doing the null checks. It is an OS-specific solution though.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list