[Issue 4621] Destructors are inherently un- at safe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 12 07:10:30 PDT 2010


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



--- Comment #13 from nfxjfg at gmail.com 2010-08-12 07:10:27 PDT ---
(In reply to comment #11)
> 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.

This isn't so much of a problem if you assume objects with finalizers are rare.
They can be collected in the next GC cycle.

> 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.

Good point. By definition, if the object is not shared(), the finalizer (or
anything) must not run on a different thread. It doesn't matter if you access
references or not. I wonder how D2 can have finalizers at all with this.

-- 
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