caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Anders Fugmann <anders@fugmann.net>
To: ygrek <ygrek@autistici.org>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Bug when printing from signal handlers?
Date: Thu, 20 Mar 2014 08:42:47 +0100	[thread overview]
Message-ID: <532A9BF7.6050705@fugmann.net> (raw)
In-Reply-To: <20140320132941.09aa04f4@kiwi.local.tld>

On 03/20/2014 06:29 AM, ygrek wrote:
>
> stdlib channels are protected with non-recursive mutex, so the deadlock on re-entrant invocation is guaranteed.
I also assumed when I first saw the behavior that it was some deadlock. 
But it seems that that is not the case as the system enters a live lock 
and just sits there burning off cpu time.

> AFAICS runtime system tries to execute signal immediately (see signal_handle in asmrun/signals_asm.c)
> and if that is not possible - records signal for later execution.
> Anyway doing complex stuff in signal handler is a bad idea, because even with delayed processing (when
> things are safe from the libc point of view) the points of invocation of OCaml signal handler are scattered
> all around the program (allocation sites) and any OCaml resource that doesn't support reentrant usage will break
> the program.

Maybe the documentation should be updated to explain how signal handling 
works and what is allowed in signal handers. Possibly also ideas on how 
to cope with these limitations.

I circumvented the problem by using unbuffered writes (Unix.write), but 
it makes me wonder if I have code erroneous code lying around.

/Anders




  reply	other threads:[~2014-03-20  7:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-19 21:21 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 [this message]
2014-03-20 20:07       ` Gerd Stolpmann
2014-03-23 10:01         ` ygrek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=532A9BF7.6050705@fugmann.net \
    --to=anders@fugmann.net \
    --cc=caml-list@inria.fr \
    --cc=ygrek@autistici.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).