--- Comment #1 from Michel Fortin <> 2010-08-12 
12:29:25 EDT ---
Additionally, I believe std.containers.Array has a race condition when stored
in the GC heap. The Array destructor checks the reference count before deciding
whether it should free the array's content or not. This reference counter is
non-shared, but the collection cycle can run on any thread so there is a race
when accessing the reference counter.

    private struct Data
        uint _refCount = 1;
        size_t _capacity;
        T[] _payload;
        this(T[] p) { _capacity = p.length; _payload = p; }

The reference counter should be made shared so it is only accessed using atomic
operations. Other fields don't need to be shared because the only time they're
accessed in the destructor is when the reference counter falls to zero and the
destructor has the only remaining reference.

This problem is also present in std.stdio.File (in addition to the other
problem above) and std.typecons.RefCounted which both use a non-shared
reference counter, rendering them unsuitable for being put in the GC heap.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to