caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Bug when printing from signal handlers?
@ 2014-03-19 21:21 Anders Peter Fugmann
  2014-03-19 22:19 ` Jesper Louis Andersen
  0 siblings, 1 reply; 7+ messages in thread
From: Anders Peter Fugmann @ 2014-03-19 21:21 UTC (permalink / raw)
  To: caml-list

Hi,

I'm experiencing a live lock while printing from a signal handler.
It seems to be triggered when the main is interrupted while printing.

The following program exposes the problem:
(tested on 4.00.1 and 4.01.0)

let rec loop () =
   print_endline "In main thread";
   loop ()

let _ =
   Sys.(set_signal sigalrm
          (Signal_handle
             (fun _ -> print_endline "In signal handler")));
   let _ = Unix.(setitimer ITIMER_REAL
                   { it_interval = 0.1; it_value = 0.1 })
   in
   loop ()

For some reason, in caml_flush_parial channel->buff becomes greater than 
channel->curr which means caml_flush never completes, as 
caml_flush_partial never returns true.

Is printing from a signal handler illegal?
I tries searching for bug on this matter but only found examples that 
printed from signal handlers.

Regards
Anders

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-03-23 10:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19 21:21 [Caml-list] Bug when printing from signal handlers? Anders Peter Fugmann
2014-03-19 22:19 ` Jesper Louis Andersen
2014-03-19 23:21   ` Gerd Stolpmann
2014-03-20  5:29     ` ygrek
2014-03-20  7:42       ` Anders Fugmann
2014-03-20 20:07       ` Gerd Stolpmann
2014-03-23 10:01         ` ygrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).