GC behavior and Allocators
safety0ff via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 4 03:36:02 PDT 2014
On Thursday, 3 July 2014 at 21:53:25 UTC, Brian Schott wrote:
>
> I think that the only sane way to solve this is to define in
> the specs for core.memory that GC.addRange will only ever store
> one entry per pointer, and that the length will be the value of
> "sz" from the most recent call to addRange.
>
> Thoughts?
I just thought a little more about this and you will always have
a race.
Consider this code:
auto a = malloc(aSize);
GC.addRange(a, aSize);
auto b = realloc(a, aSize * 2);
If realloc moves the data (a != b) and the GC runs before you can
fix up the ranges you can have invalid access during collection.
More information about the Digitalmars-d
mailing list