-
Notifications
You must be signed in to change notification settings - Fork 1.2k
IO mutex and threads #5141
Description
Original bug ID: 5141
Reporter: @ygrek
Status: resolved (set by @xavierleroy on 2012-07-04T18:00:23Z)
Resolution: suspended
Priority: normal
Severity: major
Version: 3.11.2
Category: threads
Related to: #7503
Bug description
Consider :
let () =
let ok = match Sys.argv with [|_;"ok"|] -> true | _ -> false in
Sys.set_signal Sys.sigint (Sys.Signal_handle (fun _ ->
(if ok then prerr_endline else print_endline) "signal received, sleep 1 second";
Thread.delay 1.));
while true do print_endline "ha ha ha ha ha ha ha" done
Compile with : ocamlopt -thread unix.cmxa threads.cmxa io.ml -o io
Running ./io hang and pressing Ctrl-C will deadlock :
(gdb) bt
#0 __lll_lock_wait ()
at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136
#1 0x00007f0fda04e0e9 in _L_lock_953 () from /lib/libpthread.so.0
#2 0x00007f0fda04df0b in __pthread_mutex_lock (mutex=0x1f30360)
at pthread_mutex_lock.c:61
#3 0x000000000041a1ab in caml_io_mutex_lock ()
#4 0x00000000004266fb in caml_ml_output ()
#5 0x000000000042e65c in caml_c_call ()
#6 0x0000000000000001 in ?? ()
#7 0x0000000000410e9a in camlPervasives__print_endline_298 ()
#8 0x0000000000000000 in ?? ()
Running ./io ok will behave as expected (pause 1 sec then continue).
Additional information
Reproduces :
debian x86_64 with ocaml 3.11.2 and 3.12.0
rhel4 with ocaml 3.11.2
opensolaris x86_64 with ocaml 3.10.2
Reproduces but prints "signal received" before hanging :
openbsd x86_64 with ocaml 3.11.1
FreeBSD 6.3-STABLE i386 with ocaml 3.11.2