caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] the same signal handling problem on powerpc
@ 2002-10-13 20:02 John Hale
  2002-10-13 21:37 ` Damien Doligez
  0 siblings, 1 reply; 2+ messages in thread
From: John Hale @ 2002-10-13 20:02 UTC (permalink / raw)
  To: caml-list

Let me first say how much fun programming in Caml is.

Having said that, I believe I'm experiencing the same signal handling 
problem Winfried Dreckmann brought up
http://caml.inria.fr/archives/200206/msg00039.html

Namely, I have a program that uses signals, works fine in bytecode, but 
crashes with "bus error"
in native code. i can't reproduce the problem with a small subpart. 
FWIW, my program doesn't use the C interface.
It crashes whether I use an interval timer or Unix.alarm, regardless of 
the timer being virtual or real.
Also, one alarm works fine, it's always receipt of the second alarm 
that causes a bad access at the signal handler.

This is with ocaml-3.06 on Mac OS X 10.2.1, PowerPC.  The problem goes 
away on Linux running on intel.

Here is a small example that exemplifies the kind of signal handling 
going on in the [larger] malfunctioning
program -- but *it itself does not crash*.  The key idea is that I'd 
like the mutable variable "measured_lately"
to be updated by the signal handler so that when the function "dostuff" 
checks it, it properly reflects delivery of
an alarm signal. That should be doable by either re-requesting 
Unix.alarm each time a SIGALRM is handled,
or with a self-reloading interval timer.

Since Winfried's problem was also on PowerPC (but with linux) I'm 
guessing there is something about
the specialization to PowerPC that has gone awry. anybody else 
experiencing this?

-john

> let rec dostuff measured_lately i =
>       if i=0 then () else (Unix.sleep (Random.int 10);
> 			   if (not !measured_lately) then
> 			     begin
> 			       print_string ((string_of_int i)^"\n");
> 			       flush stdout;
> 			       measured_lately := true;
> 			       dostuff measured_lately (i-1)
> 			     end
> 			   else dostuff measured_lately (i-1))
>
> let alarming_bug () =
>   begin
>     let measured_lately = ref true in
>     Sys.set_signal Sys.sigalrm (Sys.Signal_handle
> 				  (function x -> if x = Sys.sigalrm
> 				  then (measured_lately := false;
> 				    ignore (Unix.alarm 5)) else ()));
>     ignore (Unix.alarm 5);
>     dostuff measured_lately 3;
>     ignore (Unix.alarm 0)
>   end;;
>
> List.iter alarming_bug [();()];;

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] the same signal handling problem on powerpc
  2002-10-13 20:02 [Caml-list] the same signal handling problem on powerpc John Hale
@ 2002-10-13 21:37 ` Damien Doligez
  0 siblings, 0 replies; 2+ messages in thread
From: Damien Doligez @ 2002-10-13 21:37 UTC (permalink / raw)
  To: John Hale; +Cc: caml-list

On Sunday, Oct 13, 2002, at 22:02 Europe/Paris, John Hale wrote:

> Namely, I have a program that uses signals, works fine in bytecode, 
> but crashes with "bus error"
>
> This is with ocaml-3.06 on Mac OS X 10.2.1, PowerPC.  The problem goes 
> away on Linux running on intel.

Are you using the vanilla 3.06, or did you follow the instructions in
this page ? <http://caml.inria.fr/caml-macosx-howto/index.html>

There is a signal-related problem with 3.06 on MacOS 10.2, due to a
change in an undocumented API between 10.1 and 10.2.  The web page above
gives a patch to fix this problem (and also the Sys.command bug).

While I'm talking to the list, the page also explains how to get
Caml Light working on Mac OS X.

-- Damien

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-10-14 12:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-13 20:02 [Caml-list] the same signal handling problem on powerpc John Hale
2002-10-13 21:37 ` Damien Doligez

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