[Issue 14134] Free of large array does not work
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Feb 6 08:56:40 PST 2015
https://issues.dlang.org/show_bug.cgi?id=14134
Rainer Schuetze <r.sagitario at gmx.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |r.sagitario at gmx.de
--- Comment #1 from Rainer Schuetze <r.sagitario at gmx.de> ---
That was a bug in 2.066.
Contrary to the documentation free() didn't really check whether a pointer is
to the base of the allocation, and this could seriously corrupt the internal
data structures.
The check now is better, but still not perfect. The GC cannot easily determine
whether a small allocation is already free'd or not.
> If I use delete on that array, and it's an array of structs, it will call the dtor twice on that array.
The new struct destruction by the GC assumes that, if you manually call the
destructor, you also take care of manually freeing the memory with GC.free.
That way the GC will not call the destructor again.
--
More information about the Digitalmars-d-bugs
mailing list