caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: ygrek <ygrek@autistici.org>
To: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Bug when printing from signal handlers?
Date: Sun, 23 Mar 2014 18:01:28 +0800	[thread overview]
Message-ID: <20140323180128.05bb41dc@kiwi.local.tld> (raw)
In-Reply-To: <1395346042.27397.33.camel@zotac>

[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]


On Thu, 20 Mar 2014 08:42:47 +0100
Anders Fugmann <anders@fugmann.net> wrote:

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

I personally prefer to use signalfd for non-trivial signal handling, which means that
handler is invoked with specific and controlled program state.


On Thu, 20 Mar 2014 21:07:22 +0100
Gerd Stolpmann <info@gerd-stolpmann.de> wrote:

> No, there aren't any mutexes here involved - the failing program is
> single-threaded.

Indeed, the program is compiled with single-threaded runtime, so that's an additional failure scenario.

> Nevertheless it's a bit surprising that innocent-looking OCaml code
> turns out as unsafe. The current state is a bit unsatisfactory, at
> least.

Agreed, that's the point - OCaml signal handler though safe on the libc side, is nevertheless
subject to asynchronous execution at arbitrary program spots and, unless the user code
and runtime are fully reentrant, various unexpected program failures are inevitable..  

-- 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

      reply	other threads:[~2014-03-23 10:01 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
2014-03-20 20:07       ` Gerd Stolpmann
2014-03-23 10:01         ` ygrek [this message]

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=20140323180128.05bb41dc@kiwi.local.tld \
    --to=ygrek@autistici.org \
    --cc=caml-list@inria.fr \
    /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).