RefCounted no thread-safety?
Dmitry Olshansky
dmitry.olsh at gmail.com
Sun Jan 12 12:46:08 PST 2014
13-Jan-2014 00:12, Michel Fortin пишет:
> On 2014-01-12 20:08:17 +0000, Dmitry Olshansky <dmitry.olsh at gmail.com>
> said:
>
>> 12-Jan-2014 23:59, Kira Backes пишет:
>>> Hello,
>>>
>>>
>>> I was just looking at the source of std.typecons.RefCounted and it seems
>>> like it is not thread-safe at all, the count variable may be written
>>> concurrently from several threads which could cause data corruption.
>>
>> It cannot. In D everything is thread-local by default.
>> And shared(RefCounted!T) would most likely fail to compile.
>
> There's still a race when RefCounted is located in a GC-allocated memory
> block, as the destructor might get called from any thread.
> https://d.puremagic.com/issues/show_bug.cgi?id=4624
>
Awful.
The only thing worse is that arrays of structs don't have their
destructors called at all.
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list