This is similar to issue 8960:
from core/thread.d:2637
unittest
{
import core.sync.semaphore;
shared bool inCriticalRegion;
auto sem = new Semaphore();
auto thr = new Thread(
{
thread_enterCriticalRegion();
inCriticalRegion = true;
sem.notify();
Thread.sleep(dur!"msecs"(1));
inCriticalRegion = false;
thread_exitCriticalRegion();
});
thr.start();
sem.wait();
assert(inCriticalRegion);
thread_suspendAll();
assert(!inCriticalRegion);
thread_resumeAll();
}
Started thread may terminate before executing se,.wait() thus leaving inCriticalSection = false. The root of the problem is absence of supporting code to launch thread and wait for a semaphore. This makes current unittest to speculate whether thread will terminate before waiting semaphore or not.
Example of non-deterministic failure:
d.puremagic.com/test-results/pull.ghtml?projectid=1&runid=829992&logid=5
Comment #1 by maxim — 2013-12-22T13:12:46Z
*** This issue has been marked as a duplicate of issue 11519 ***