What a nice bug!

Denis Koroskin 2korden at gmail.com
Mon May 25 17:48:03 PDT 2009

Sorry for bumping this thread once, but I came across this issue again today.

It took my all the day to cut my project as much as possible while still preserving this bug.

Changing nearly anything also vanishes the bug. Here are some examples:

1) There are a few cases where I extend an empty interface:
module dice.build.Source;
interface Source {}

module dice.build.d.DSourceFile;
class DSourceFile : Source { /* ... */ }

Removing an interface inheritance makes bug disappear.

2) There are more than 20 empty D source files in this project (!), and removing _any_ of them also makes this bug disappear!

3) Some data structures got paddings during code simplification:

module dice.filesystem.FileSystemMonitor;
struct MonitorInfo
    void[] buffer;
    char[13] padding; // reducing it to 12 or lower makes bug disappear

4) There a few cases like this in the code:

module dice.filesystem.FileSystemMonitor;
buffer.length = 4096;

Reducing this number to 4095 or lower also makes bug disappear.

5) There is a do-nothing thread, which is never accessed. Its run method looks like this:
module dice.filesystem.FileSystemMonitor;

private final void run()
    while (true) {

Making run() method empty (i.e. letting this thread finish) causes a crash in another part of a program - I have no idea why:
An exception was thrown while finalizing an instance of class ui.control.impl.win32.Win32TreeControlImpl.Win32TreeControlImpl

This class has a parent with a __dtor that doesn't do anything special. Removing ~this still crashes the program.

Looks like a bad codegen or a GC issue, although it may be my bug, too (but I have no idea about possible reasons).
I suspect it have something to do with memory management, because I could easily remove code that doesn't allocate anything, and couldn't remove most of the code that allocates.

I tried disabling GC, but it didn't help.

Could anyone take a look at it, try to reproduce or give some ideas/advices? Any help is _very_ appreciated!

Here is my test-case: http://www.sendspace.com/file/2laod7 (I couldn't find a better place to store attachment, sorry)

Extract its contents to d:\Projects\dice (or C:\Projects\dice and reflect the change in main.d)
Bug may not be reproducible otherwise. Build and run it with build_and_run.bat. Win32 only (as of now).

Also, while debugging this I came across an OPTLINK unexpected termination bug during linking an executable. Adding one more empty file, or removing another one resulted in proper linking. Shall I submit a bugreport about it? I didn't do it because there are lots of similar ones already (possible duplication), test-case is huge, and chances are it won't get fixed anyway.

More information about the Digitalmars-d mailing list