On Thu, 20 Mar 2014 08:42:47 +0100 Anders Fugmann 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 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.. --