Thread overview |
---|
December 04, 2006 [Issue 645] New: Race condition in std.thread.Thread.pauseAll | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=645 Summary: Race condition in std.thread.Thread.pauseAll Product: D Version: 0.176 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: bugzilla@digitalmars.com ReportedBy: kinaba@is.s.u-tokyo.ac.jp Line 334 and 335 @ phobos/std/thread.d > if (t && t !is tthis && t.state == TS.RUNNING) > t.pause(); The thread t may change its state before t.pause() and after t.state == TS.RUNNING. For example, it may finish running. If that happens, an exception is thrown: > Error: Thread error: cannot pause and thus the whole execution of pauseAll() fails. But IMHO pauseAll should not fail. The situation can be reproduced by the following code. ------------------------ // credit goes to http://f17.aaa.livedoor.jp/~labamba/?BugTrack%2F26 import std.thread; class DoNothing : Thread // threads that does nothing { int run() { return 0; } } class StartAndTerminateLoop : Thread { // infinitely starting and terminating threads int run() { for(;;) {Thread t=new DoNothing; t.start; t.wait;} return 0; } } void main() { (new StartAndTerminateLoop).start; for(;;) { Thread.pauseAll; Thread.resumeAll; } // infinitely repeat pauseAll/resumeAll // and eventually triggers the race hazard } ------------------------ One way to solve this problem is providing a private non-throwing pause() function and using it in pauseAll(). -- |
October 27, 2007 [Issue 645] Race condition in std.thread.Thread.pauseAll | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=645 braddr@puremagic.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED ------- Comment #1 from braddr@puremagic.com 2007-10-27 11:59 ------- Please see the patch attached to bug 318. It should fix this bug as well. -- |
November 04, 2007 [Issue 645] Race condition in std.thread.Thread.pauseAll | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=645 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED ------- Comment #2 from bugzilla@digitalmars.com 2007-11-03 21:41 ------- Fixed dmd 1.023 and 2.007 -- |
Copyright © 1999-2021 by the D Language Foundation