digitalmars.D.bugs - [Issue 1164] New: Wrong order of memory deallocation
- d-bugmail puremagic.com (26/26) Apr 19 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1164
- d-bugmail puremagic.com (15/15) Apr 19 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1164
- Marcin Kuszczak (8/15) Apr 19 2007 Hmmm... but it doesn't help much with cleaning up on destruction. When
- Jarrett Billingsley (6/8) Apr 19 2007 I would. I've never understood the whole "never know when / if dtors wi...
- d-bugmail puremagic.com (8/8) Apr 19 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1164
- d-bugmail puremagic.com (4/4) Apr 19 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1164
- d-bugmail puremagic.com (9/9) Apr 20 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1164
http://d.puremagic.com/issues/show_bug.cgi?id=1164 Summary: Wrong order of memory deallocation Product: D Version: 1.012 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: aarti interia.pl class Storage { void sync() {}; } class Test { Storage s; this() {s=new Storage;} ~this() {s.sync();} } void main() { new Test; } Code above triggers Segmentation fault. Didn't test it on Windows, but probably it is not platform specific issue. --
Apr 19 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1164 deewiant gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #1 from deewiant gmail.com 2007-04-19 14:10 ------- Invalid. http://www.digitalmars.com/d/class.html#destructors has the following passage: "When the garbage collector calls a destructor for an object of a class that has members that are references to garbage collected objects, those references are no longer valid. This means that destructors cannot reference sub objects. This rule does not apply to auto objects or objects deleted with the DeleteExpression." --
Apr 19 2007
d-bugmail puremagic.com wrote:"When the garbage collector calls a destructor for an object of a class that has members that are references to garbage collected objects, those references are no longer valid. This means that destructors cannot reference sub objects. This rule does not apply to auto objects or objects deleted with the DeleteExpression."Hmmm... but it doesn't help much with cleaning up on destruction. When collecting would be done in two phases (1. calling all destructors, 2. deallocating memory) maybe it would work. Maybe I should mark it as enhancement? -- Regards Marcin Kuszczak (Aarti_pl)
Apr 19 2007
"Marcin Kuszczak" <aarti interia.pl> wrote in message news:f08g87$icb$1 digitalmars.com...d-bugmail puremagic.com wrote: Maybe I should mark it as enhancement?I would. I've never understood the whole "never know when / if dtors will be called" thing. It's just plain irritating, because face it, sometimes you _do_ need to destroy things (like non-memory resources) when an object is collected.
Apr 19 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1164 aarti interia.pl changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Status|RESOLVED |REOPENED Resolution|INVALID | --
Apr 19 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1164 ------- Comment #3 from aarti interia.pl 2007-04-20 01:50 ------- Reopened and marked as enhancement. --
Apr 19 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1164 ------- Comment #4 from ddparnell bigpond.com 2007-04-20 02:20 ------- It also fails in Windows. The workaround is to use the 'scope' attribute. void main() { scope Test t = new Test; } --
Apr 20 2007