caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] signal-unsafety of %!
@ 2013-03-15 14:30 Matej Kosik
  2013-03-15 14:36 ` oliver
  0 siblings, 1 reply; 4+ messages in thread
From: Matej Kosik @ 2013-03-15 14:30 UTC (permalink / raw)
  To: caml-list; +Cc: Matej Kosik

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

Hi,

When I compile the attached program

  (with compilers available directly from Debian's repositories)

I can observe a (non-deterministic) deadlock.

When I remove

	%!

from the printf function inside the SIGALRM's handler, the deadlock never seem to occur.

Obviously, interference can be easily introduced in concurrent programs; I was just surprised that even something like

	%!

can cause it.

Isn't this something, that could be avoided in this case?

[-- Attachment #2: main.ml --]
[-- Type: text/plain, Size: 173 bytes --]

open Unix

;;

Sys.set_signal Sys.sigalrm
               (Sys.Signal_handle (fun _ -> Printf.printf "H%!"));
ignore (Unix.alarm 1);
while true do
  Printf.printf ".%!"
done

[-- Attachment #3: Makefile --]
[-- Type: text/plain, Size: 94 bytes --]

main : % : %.ml
	ocamlfind c -linkpkg -package unix $< -o $@

clean :
	rm -f *.cmo *.cmi main

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

end of thread, other threads:[~2013-03-15 16:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-15 14:30 [Caml-list] signal-unsafety of %! Matej Kosik
2013-03-15 14:36 ` oliver
2013-03-15 15:56   ` Matej Kosik
2013-03-15 16:02     ` oliver

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).