https://issues.dlang.org/show_bug.cgi?id=4890

--- Comment #25 from Sean Kelly <s...@invisibleduck.org> ---
Hrm... at one point thread_entryPoint called Thread.add to add itself, but I
think the add was moved to Thread.start at some point to deal with a race.  I
had a comment in Thread.start explaining the rationale, but it looks like
Thread.start has been heavily edited and the comment is gone.  Either way,
having Thread.start call Thread.add *after* pthread_create is totally wrong, as
it leaves a window for the thread to exist and be allocating memory but be
unknown to the GC.

I think I'll have to roll back thread.d to find my original comments and see
how it used to be implemented.  Something was clearly changed here, but there's
no longer enough info to tell exactly what.

I've got to say that seeing these and other changes in core.thread without
careful documentation of what was changed and why it was done is very
frustrating.  There's simply no way to unit test for the existence or lack of
deadlocks, and the comments in this module were built up over years of bug
fixes to explain each situation and why the code was the way it was.  If
someone changes the code in this module they *must* be absolutely sure of what
they are doing and document accordingly.

--

Reply via email to