Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005013OCaml~DO NOT USE (was: OCaml general)public2010-04-01 00:202011-05-29 12:19
Assigned Toxleroy 
PlatformOSOS Version
Product Version3.11.1 
Target VersionFixed in Version3.12.0+dev 
Summary0005013: Condition.broadcast may not wake up all threads in native Windows build
DescriptionIf two threads are waiting on a condition, Condition.broadcast should wake both of them up. However, if the first thread to be awoken waits on the same condition again it may be woken up again instead of the other thread.

I marked reproducibility as random since it depends on threads, but it happens about 50% of the time.

Linux and bytecode-Windows seem to be immune from this problem.
Additional InformationThe attached code can display the problem. Each line of the output begins with the thread which is printing it. two threads "t1" and "t2" wait on condition "c". The main thread then broadcasts the condition, which SHOULD wake up both threads eventually. On Linux this program always outputs:
 1: waiting first
 2: waiting first
 2: going from broadcast; waiting second
 1: going from broadcast; waiting second

indicating that both threads woke up. On Windows the program may return:
 1: waiting first
 2: waiting first
 1: going from broadcast; waiting second
 2: going from broadcast; waiting second

which is also correct (the threads were woken up in the opposite order as on Linux, but that doesn't matter). However Windows may also return the following:
 1: waiting first
 2: waiting first
 2: going from broadcast; waiting second
 2: going from broadcast a second time

basically the broadcast woke up thread #2 TWICE, without waking up thread #1 at all. If this were a real program which was waiting on thread #1 to continue it would deadlock.
TagsNo tags attached.
Attached Files? file icon [^] (838 bytes) 2010-04-01 00:20 [Show Content]

- Relationships

-  Notes
omion (reporter)
2010-04-01 03:06

Actually, after further testing, it looks like it only occurs in 64-bit Windows compiles. My 32-bit compilation of the code seems to work properly...
xleroy (administrator)
2010-04-27 10:04

The Win32 implementation of condition variables was indeed incorrect w.r.t. Condition.broadcast. Reimplemented condition variables under Win32 in a way that should conform to POSIX semantics. Will go in 3.12.0.

- Issue History
Date Modified Username Field Change
2010-04-01 00:20 omion New Issue
2010-04-01 00:20 omion File Added:
2010-04-01 03:06 omion Note Added: 0005283
2010-04-01 11:13 xleroy Assigned To => xleroy
2010-04-01 11:13 xleroy Status new => acknowledged
2010-04-27 10:04 xleroy Note Added: 0005394
2010-04-27 10:04 xleroy Status acknowledged => resolved
2010-04-27 10:04 xleroy Resolution open => fixed
2010-04-27 10:04 xleroy Fixed in Version => 3.12.0+dev
2011-05-29 12:19 xleroy Status resolved => closed
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker