The following piece of code seems to crash consistently on Windows (but it
seems to also affect Linux, and that's where I found it - particularly, it only
seemed to crash depending on the content of a static constructor: removing
almost any line from it removed the crash; the minimal test case was large, so
I have not included it).

import std.stream;
import std.stdio;

class X
{
     Stream output;

     this(Stream output)
     {
          this.output = output;
     }

     void close()
     {
           output.close();
     }

     ~this()
     {
          close();
     }
}

int main(string[] args)
{
     new X(new std.stream.File("x.log", FileMode.OutNew));
     return 0;
}

Adding "writeln(output.isOpen);" to the close() method removes the crash (and
returns true before .close() and false after .close(), as one would expect). On
the large test case for Linux, however, the crash persisted even with isOpen(),
and just "touching" the object crashed the program (it looked like I was
working with an already released object).

PS: Excuse me if I didn't follow all rules for reporting bugs, or if I'm
missing something obvious. But the code is pretty simple and I can't think
about any obvious cause.

Reply via email to