Am Fri, 11 Aug 2017 18:44:56 +0000
schrieb bitwise <>:

> […]

That can't work and here is why: Druntime employs a
conservative GC that will treat several things as potential
pointers to GC memory. From the top of my head, the entire
stack as well as void[] arrays and unions that contain
Some integer variable on the stack or a chunk of a void[] that
happens to have the same value as your GC pointer will keep it
alive. Same for a union of an integer and a pointer where you
have set the integer part to the address of your GC memory
These misidentifications (false pointers) can become a real
problem on 32-bit systems, where due to the small address
space many things can look like valid pointers and keep GC
memory alive that should long since have been recycled.

P.S.: Also keep in mind that if you were to run
multi-threaded, the ptr you test for could have been recycled
and reassigned between GC.collect() and GC.addrOf(). Some
unittesting frameworks for example run the tests in parallel.


Reply via email to