[dmd-internals] changeset 455
Robert Clipsham
robert at octarineparrot.com
Wed Apr 28 14:17:21 PDT 2010
On 28/04/10 21:54, Andrei Alexandrescu wrote:
>> But surely once a process has been sent SIGSEGV, we can't really recover
>> from a generic handler? The process at that point is in an unknown
>> state. The correct behaviour on SIGSEGV is to die.
>
> I agree. But couldn't the process printf() a string before dying?
There's a GNU library for handling this, libsigsegv (
http://libsigsegv.sourceforge.net/ ). I took the liberty of downloading
and inspecting this, it's 5659 LoC to handle segfaults (So say, 3000 if
we rewrote it in D :P). That's a lot of extra code to handle a segfault
for unittests. Add to this not all platforms support it, and it needs
reimplementing on every platform. If you want this code in
druntime/phobos then you'll have to write it from scratch due to
licensing issues and be unable to look at this well written/tested
library as a reference... It seems like a lot of extra effort for
something I maintain should be done with a debugger.
Not to mention the fact that printing a string before dying is as good
as useless. You know the order the unittests are being run, as you wrote
the code... From this you can figure out which case is failing (unless
it's the first test of an unknown file, but again, debugger). You just
need to look what the last test case was to run before the segfault.
Alternatively you could get the unittester to do something along the
lines of:
----
writef( "%s:%d: ", file, line );
fflush(stdout);
writefln( "%s", runTest() == true ? "success" : "fail" );
----
Which would allow you to see the test that was being run before it runs.
More information about the dmd-internals
mailing list