Bug 6223 – Crash on exit when embeeding std.stream.File in a class.

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-06-29T14:18:00Z
Last change time
2016-10-18T08:09:10Z
Keywords
bootcamp
Assigned to
nobody
Creator
gamezelda2

Comments

Comment #0 by gamezelda2 — 2011-06-29T14:18:56Z
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: Sorry if I'm missing something obvious and this is a not a bug, but the behaviour is odd, at least. Also, I posted a message directly to the mailing list - I found that bugzilla.digitalmars.com was only for DMC, so I thought that I should use the mailing list for D directory - sorry!
Comment #1 by dfj1esp02 — 2016-10-18T08:09:10Z
*** This issue has been marked as a duplicate of issue 15595 ***