[dmd-internals] changeset 455

Andrei Alexandrescu andrei at erdani.com
Wed Apr 28 14:45:56 PDT 2010


On 04/28/2010 04:17 PM, Robert Clipsham wrote:
> 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.

Ouch.

> 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.

The problem is scale. Phobos is pretty large already. I did make changes 
in unittests as you suggest above, but there are a lot of those to make. 
Besides, when compiling Phobos as one unit and unittesting everything, 
all unittests are run in one shot so you don't know about modules and stuff.

I improved that by painstakingly changing the build process to print and 
unittest one Phobos module at a time, while unittests are disabled in 
all other modules. That does help but is still far from perfect.

(Perfect: when it fails tell me where.)

> 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.

That would be too noisy.


Andrei


More information about the dmd-internals mailing list