digitalmars.D.bugs - [Issue 11454] New: Race in core.thread unit test causing transient failures
- d-bugmail puremagic.com (54/54) Nov 06 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11454
- d-bugmail puremagic.com (13/13) Feb 08 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11454
https://d.puremagic.com/issues/show_bug.cgi?id=11454 Summary: Race in core.thread unit test causing transient failures Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: druntime AssignedTo: nobody puremagic.com ReportedBy: safety0ff.bugz gmail.com 08:36:54 PST --- The culprit code is from line 2637 of src/core/thread.d [1] It caused a test failure in an unrelated pull request (https://d.puremagic.com/test-results/pull.ghtml?projectid=1&runid=779542 ,) the PR simply removed a no-op and should not have caused any non-failing tests to begin failing. My hypothesis is that Thread.sleep is used to yield the secondary thread, but the secondary thread gets rescheduled before the main thread, causing the first assertion to fail. Two solutions I've come up with: - If the compiler does not treat shared variables as a C compiler treats "volatile" variables, then we can add a secondary semaphore ensuring the assertion is executed prior to the secondary thread proceeding. - Otherwise the assertion is redundant due to the semaphore and can be removed. [1] -------------------------------------------- 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(); } -------------------------------------------- -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 06 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11454 safety0ff.bugz <safety0ff.bugz gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P2 |P4 Status|NEW |RESOLVED Resolution| |DUPLICATE 23:44:12 PST --- Even though I created this report first, I'll mark this one as the duplicate. *** This issue has been marked as a duplicate of issue 11519 *** -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 08 2014