www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14336] New: Invalid memory access in struct destructor in


          Issue ID: 14336
           Summary: Invalid memory access in struct destructor in std.uni
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: thecybershadow gmail.com
                CC: blah38621 gmail.com, dmitry.olsh gmail.com

Created attachment 1495
  --> https://issues.dlang.org/attachment.cgi?id=1495&action=edit
Valgrind log

Valgrind (with my Valgrind branch [1]) reports an incorrect memory access in
std.uni.CowArray destructors (see attachment).

It looks like the following happens:

- The destructor is finalizing a heap-allocated array of InversionList!GcPolicy
- InversionList doesn't have a destructor, but it has a CowArray field
("data"). CowArray has a destructor, so one is automatically generated for
- CowArray!GcPolicy.~this calls the refCount  property.
- The refCount  property attempts to refer to the heap-allocated (via GcPolicy)
uint[] data field, which has already been destroyed by the GC. As I understand,
this is an invalid memory access.


Mar 25 2015