[Issue 4621] Destructors are inherently un- at safe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 12 06:54:52 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4621



--- Comment #11 from Michel Fortin <michel.fortin at michelf.com> 2010-08-12 09:54:51 EDT ---
(In reply to comment #8)
> C# and Java have safe finalizers.

Indeed. Java allows resurrection, which means that if you leak a reference to
an object during the collection, the GC won't collect that object and will
leave it in the state it was after the finalizer was called.

This is an interesting idea, but I see two reasons it'll not work fro D. First,
D doesn't emit special code notifying the GC when assigning to a pointer, so
the GC would have to do a full scan again after a collection just to check if
someone resurrected a memory block.

The second reason is the D2 multithreading model. The GC might run on a
different thread. If you resurrect a non-shared object, that object won't live
on the same thread anymore but might continue to reference non-shared memory
from other threads. This is in violation of the thread-safe type system.

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


More information about the Digitalmars-d-bugs mailing list