Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006771OCamlplatform support (windows, cross-compilation, etc)public2015-02-04 17:482017-02-16 15:18
Reporterenrico 
Assigned Toxleroy 
PriorityhighSeverityminorReproducibilityrandom
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version4.01.0 
Target Version4.03.0+dev / +beta1Fixed in Version4.03.0+dev / +beta1 
Summary0006771: Thread lock up
DescriptionEspecially on windows (but also on Linux) it seems that:
- at least 2 threads blocked on a read (at least 3 on linux)
- some data is finally available on one of their fd, but no thread is woken up
Steps To ReproduceTest case in attachment. It is a stripped down Coq, sorry for the not exactly clean and readable code.

"server" spawns "client mitm" that in turn spawns "client".

The MITM runs two threads talking with server and client respectively.
The two threads communicate via a queue protected with a mutex and a condition.

On Linux things mostly work here, and rarely hang (and only if I add to the picture more threads). On my Windows 7 virtual machine the test case hangs systematically.
Additional InformationThis bug affects Coq 8.5beta1 (where a huge hack works around it).
TagsNo tags attached.
Attached Fileszip file icon bug.zip [^] (13,294 bytes) 2015-02-04 17:48
diff file icon bug-workaround.diff [^] (1,302 bytes) 2015-05-14 02:42 [Show Content]

- Relationships
duplicate of 0005325closed Blocked Unix.recv in one thread blocks Unix.send in another thread under Windows 
related to 0004466closed Unix.select on Windows not handling reads and writes to same socket 

-  Notes
(0013226)
shinwell (developer)
2015-02-05 08:23

Could you please provide a test case that hangs on Linux?
(0013228)
enrico (reporter)
2015-02-05 10:18

I'm pretty sure I've seen that hang on linux too, but I can't reproduce it now by adding more "bouncers" to the code I've attached.
(0013231)
dim (developer)
2015-02-05 11:46
edited on: 2015-02-05 11:46

If it only hangs on windows, could this be related to 0005325?

(0013235)
enrico (reporter)
2015-02-05 13:04

Could be, on Windows we use sockets (the code I've attached can do with pipes too but on Windows we go for sockets). From the bug report you link it is
a bit unclear to me which OCaml version I could test in order to see it it solves the bug (on Win).

But I'm sure I've seen it hang on Linux too, even if today I cannot reproduce
it by playing with the small example I've attached.
(0013850)
shinwell (developer)
2015-05-06 21:47

Damien is going to see if he can reproduce this on Windows.
(0013908)
doligez (administrator)
2015-05-12 17:35

Can't reproduce with the Cygwin version of OCaml. Will try with MSVC and Mingw.
(0013920)
doligez (administrator)
2015-05-13 16:54

Reproduced with MSVC.
(0013921)
enrico (reporter)
2015-05-13 18:11

Sorry for not being clear from the very beginning, I've been using the ocaml installer for windows available here: http://protz.github.io/ocaml-installer/ [^]
(0013926)
doligez (administrator)
2015-05-14 02:43

I'm pretty sure this is a duplicate of 0005325: you have one thread blocked on read on a socket, and another thread tries to write, and blocks.

In your case, there is an easy workaround: use two sockets instead of one (see attached diff, which fixes the problem on your test case).

This bug won't be fixed before 4.02.2.
(0015033)
xleroy (administrator)
2015-12-04 15:01

See proposed fix https://github.com/ocaml/ocaml/pull/331 [^] Re-test most welcome.
(0015083)
xleroy (administrator)
2015-12-09 15:47

Fix committed to trunk, will be in 4.03. Re-test most welcome.
(0015090)
frisch (developer)
2015-12-09 16:15

I confirm that the attached example does not hang with trunk (tested with the MSVC 32 port).
(0015097)
xleroy (administrator)
2015-12-09 18:15

Thanks a million for the re-test. We're making progress!

- Issue History
Date Modified Username Field Change
2015-02-04 17:48 enrico New Issue
2015-02-04 17:48 enrico File Added: bug.zip
2015-02-05 08:23 shinwell Note Added: 0013226
2015-02-05 10:18 enrico Note Added: 0013228
2015-02-05 11:46 dim Note Added: 0013231
2015-02-05 11:46 dim Note Edited: 0013231 View Revisions
2015-02-05 13:04 enrico Note Added: 0013235
2015-02-09 17:59 doligez Priority normal => high
2015-02-09 17:59 doligez Status new => acknowledged
2015-02-09 17:59 doligez Target Version => 4.02.2+dev / +rc1
2015-05-06 21:47 shinwell Note Added: 0013850
2015-05-06 21:47 shinwell Assigned To => doligez
2015-05-06 21:47 shinwell Status acknowledged => assigned
2015-05-12 17:35 doligez Note Added: 0013908
2015-05-13 16:54 doligez Note Added: 0013920
2015-05-13 18:11 enrico Note Added: 0013921
2015-05-14 02:42 doligez File Added: bug-workaround.diff
2015-05-14 02:43 doligez Note Added: 0013926
2015-05-14 02:43 doligez Category OCaml runtime system => OCaml windows
2015-05-14 02:43 doligez Target Version 4.02.2+dev / +rc1 => 4.02.3+dev
2015-05-14 02:43 doligez Relationship added duplicate of 0005325
2015-07-10 17:35 doligez Target Version 4.02.3+dev => 4.03.0+dev / +beta1
2015-11-29 15:05 xleroy Relationship added related to 0004466
2015-12-04 15:01 xleroy Note Added: 0015033
2015-12-09 15:47 xleroy Note Added: 0015083
2015-12-09 16:15 frisch Note Added: 0015090
2015-12-09 16:15 frisch Status assigned => resolved
2015-12-09 16:15 frisch Fixed in Version => 4.03.0+dev / +beta1
2015-12-09 16:15 frisch Resolution open => fixed
2015-12-09 16:15 frisch Assigned To doligez => xleroy
2015-12-09 18:15 xleroy Note Added: 0015097
2017-02-16 15:18 xleroy Status resolved => closed
2017-02-23 16:46 doligez Category OCaml windows => platform support (windows, etc)
2017-02-23 17:16 doligez Category platform support (windows, etc) => platform support (windows, cross-compilation, etc)


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker