[Issue 4147] New: Failing inner expression leaves ghost-reference to outer expression on GC which is errenously finalized

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 2 11:14:28 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4147

           Summary: Failing inner expression leaves ghost-reference to
                    outer expression on GC which is errenously finalized
           Product: D
           Version: future
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: webmaster at aj-productions.de


--- Comment #0 from Andreas Jung <webmaster at aj-productions.de> 2010-05-02 11:14:25 PDT ---
Created an attachment (id=620)
Demonstration of the bug - define "DEMO_FAILURE" during compilation to see the
bug in action.

Using the latest DMD 2.043.

Please refer to the attachment for a complete example. In short...

Given the following expression:
"auto parent = new Parent( new FailingChild() );".

"FailingChild::this()" throws an exception and "Parent::this( ... )" never gets
called.

The problem: The GC tries to finalize "parent", despite it has never been
constructed.

This
- compromised exception safety.
- causes hard-to-find bugs in large scale frameworks, since code is executed in
objects that the programmer is not even aware of.


Without knowing the excact implementation details of the GC, my "guess" on the
problem is: A GC-root to "parent" is added, before "FailingChild::this()" is
evaluated.

My "guess" on the solution: Add the GC-root to "parent" after the inner
expression "FailingChild::this()" is evaluated.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list