www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3237] New: Access Violation during reference counting

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3237

           Summary: Access Violation during reference counting
           Product: D
           Version: 2.032
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bartosz relisoft.com


RcName is a struct that does reference counting. When I store an instance of
RcName in an object, everything seems to go fine, except that I get an access
violation during the final destruction.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 08 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3237





--- Comment #1 from Bartosz Milewski <bartosz relisoft.com>  2009-08-08
12:31:46 PDT ---
Created an attachment (id=439)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=439)
test case for access violatin while reference counting

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 08 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3237


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com




--- Comment #2 from Walter Bright <bugzilla digitalmars.com>  2009-08-08
13:23:38 PDT ---
compile with -gc and run under windbg, the windows debugger.

Shows that it crashes because _cnt is null in the first line of release().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 08 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3237





--- Comment #3 from Bartosz Milewski <bartosz relisoft.com>  2009-08-08
15:18:14 PDT ---
Created an attachment (id=440)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=440)
simplified case with a write in the destructor of Counter

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 08 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3237





--- Comment #4 from Bartosz Milewski <bartosz relisoft.com>  2009-08-08
15:20:08 PDT ---
I simplified the example. It turns out that the destructor of a class object
Counter is called. I have no idea what mechanism may call the destructor other
than GC. A new file attached.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 08 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3237


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




--- Comment #5 from Walter Bright <bugzilla digitalmars.com>  2009-08-14
22:49:38 PDT ---
The cause of the crash is there is a dependency in the code on the order in
which the gc runs the destructors on collected objects. Dependency on this
order is not valid D code.

Generally, one cannot refer to other objects on the GC heap when inside a
destructor for a GC object.

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