Version française
Home     About     Download     Resources     Contact us    
Browse thread
Freezing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Baelde <david.baelde@g...>
Subject: Freezing
Hi list,

This could be a bug report but I have only a very bad description of
it, and it may also be nothing but an unfortunate feature...

I have a program streaming audio, and occasionally downloading files,
using ocaml-smbclient wrapped in ocaml-fetch. I want to avoid too long
(or frozen) downloads. To do so, here is essentially the code I use:

<<<
flush_all () ;
let pid = Unix.fork () in
if pid = 0 then begin
  ignore (Unix.alarm 20) ;
  Fetch.cp there here ;
  exit 0
end else
  Unix.waitpid [] pid
>>>

It's that simple (modulo the mess inside the Fetch.cp) and it works as
it should.. until some download process gets stuck, never returns. At
the end of this message is the gdb trace I got from such a frozen
process. It looks like the process wants to flush IO (could it be part
of the exit procedure ?) but cannot because some other thread is
blocking.

The main process is threaded but the child isn't. Isn't it weird that
it gets blocked in such a way ? Gdb doesn't show me any other thread
in the child process.

Another question: assuming this kind of hangup is unavoidable if I try
to flush in a threaded process, is there a way to terminate a caml
process without any extra possibly-blocking stuff ?

I'm sorry to experience and report such a mess..

(gdb) bt
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7bc556e in __lll_mutex_lock_wait ()
   from /lib/tls/i686/cmov/libpthread.so.0
#2  0xb7bc323b in pthread_cond_signal@@GLIBC_2.3.2 ()
   from /lib/tls/i686/cmov/libpthread.so.0
#3  0x08066ad5 in caml_thread_enter_blocking_section ()
#4  0x0806c006 in caml_enter_blocking_section ()
#5  0x08066c72 in caml_io_mutex_lock ()
#6  0x0807025d in caml_ml_flush ()
#7  0x08079f8d in caml_interprete ()
#8  0x08075eb0 in caml_callbackN_exn ()
#9  0x08075efa in caml_callback_exn ()
#10 0x080670b8 in caml_thread_start ()
#11 0xb7bc0e60 in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#12 0xb7afe8ee in clone () from /lib/tls/i686/cmov/libc.so.6