Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signal handling ?bug difference between bytecode and native #7942

Closed
vicuna opened this issue Nov 1, 2002 · 4 comments
Closed

signal handling ?bug difference between bytecode and native #7942

vicuna opened this issue Nov 1, 2002 · 4 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Nov 1, 2002

Original bug ID: 1466
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: John Hale
Version: 3.06 + ocaml-3.06-macosx-3.patch
OS: Mac OS X 10.2.1 6D52
Submission from: goedel.cog.jhu.edu (128.220.29.8)

bug report

November 1st 2002
John Hale
hale@cogsci.jhu.edu
file located at:
http://www.cog.jhu.edu/grad-students/hale/hale-bug-report.tar.gz

The bug is a bus error that stops the native version of the program.
The byte code version works fine.

This program is a natural language parser which is relatively expensive to run.
It works by constructing a "chart" of records about possible constituents that
might explain the string its presented with.

Since this process is so expensive, I want to print out at periodic intervals
an
indication of how large the chart is (there is also another data structure
called
the agenda whose size is interesting). Rather than constantly calling Unix time
functions to see if it's time to determine and print out the sizes of these
structures,
I'd like to use signals so that the operating system can notify the program to
do so
at user-specifiable intervals.

The idea is that, at initialization time, a signal handler will be set up

runme.ml:607
let measured_lately = ref true in
Sys.set_signal Sys.sigalrm (Sys.Signal_handle
(function x -> if x<>Sys.sigalrm then ()
else measured_lately := false ));
ignore (Unix.setitimer Unix.ITIMER_REAL
{Unix.it_interval=measurechartsizeinterval;
Unix.it_value=measurechartsizeinterval});

whose only function is to change the value of a ref cell called
"measured_lately".
Then, in the main loop of the program this value will be constantly tested.

chart.ml:200
if (!t) then () else
(print_stat st chart q; (* if it's false the alarm has gone off *)
flush stdout;
t := true);
exhaust t st chart q inf

this is in the recursive function "exhaust" (meaning "exhaustively apply the
grammar
rules to the entries already in the chart) in the module Chart. The test is
made
just before the function tail-recurs.

To replicate the bug, unpack the archive and issue

% make runme

on the command line. This should build the native code version that bombs with a
bus error
on my system. To exercise the (working) bytecode version, uncomment the #load
lines at the
top of runme.ml, and comment the final line that calls "parse". Then runme.ml
can be
#use'd in the toplevel and you can issue the parse command manually. this works
fine for me
in that status messages about the size of the chart and agenda are printed out
at 5 second
intervals. This interval is set in the "measurechartsizeinterval" variable on
line 582 in runme.ml.

My system is
Objective Caml version 3.06 including the patch from
http://caml.inria.fr/caml-macosx-howto/index.html
Mac OS X 10.2.1 build 6D52
PowerBook G4

I'm eager to hear of any news about this issue, whether it's a problem with my
code or something
to complain about to Apple -- whatever -- please keep me posted. I am a huge
O'Caml fan and
want to use signals :)

best,
-john

@vicuna
Copy link
Author

vicuna commented Nov 4, 2002

Comment author: administrator

Thanks for your bug report.

The bug is a bus error that stops the native version of the program.
The byte code version works fine.

I have reproduced the bug with the working version, and I will
investigate it. However, this is the kind of bug that's hard to
find, so don't expect a quick resolution.

Since this process is so expensive, I want to print out at periodic intervals
an
indication of how large the chart is (there is also another data structure

If you're not too picky about the frequency of the reports, you can
work around the bug by using Gc.create_alarm instead.

-- Damien

@vicuna
Copy link
Author

vicuna commented Nov 4, 2002

Comment author: administrator

The bug is a bus error that stops the native version of the program.
The byte code version works fine.
[when using a signal handler]

Please try the following patch, which should fix your bug. There
must be another bug somewhere, because one of my runs ended with
Segment violation (not Bus error), but I can't seem to reproduce
the problem.

Note that this patch is against the already-patched version of
signals.c; if you want to restart from scratch, the patch at
http://caml.inria.fr/caml-macosx-howto/ocaml-3.06-macosx-4.patch
now includes this fix.

-- Damien

Index: asmrun/signals.c

RCS file: /net/pauillac/caml/repository/csl/asmrun/signals.c,v
retrieving revision 1.65
diff -c -r1.65 signals.c
*** signals.c 2002/09/23 18:03:56 1.65
--- signals.c 2002/11/04 16:23:09


*** 342,348 ****
--- 342,352 ----
#ifdef POSIX_SIGNALS
sigact.sa_handler = act;
sigemptyset(&sigact.sa_mask);

  • #ifdef SYS_rhapsody
  • sigact.sa_flags = SA_SIGINFO;
  • #else
    sigact.sa_flags = 0;
  • #endif
    if (sigaction(sig, &sigact, &oldsigact) == -1) sys_error(NO_ARG);
    oldact = oldsigact.sa_handler;
    #else

*** 538,549 ****
struct sigaction act;
act.sa_handler = (void ()(int)) trap_handler;
sigemptyset(&act.sa_mask);
! #if defined(SYS_rhapsody) || defined(SYS_aix)
! #ifdef DARWIN_VERSION_6
! act.sa_flags = SA_SIGINFO;
! #else
act.sa_flags = 0;
! #endif
#else
act.sa_flags = SA_NODEFER;
#endif
--- 542,551 ----
struct sigaction act;
act.sa_handler = (void (
)(int)) trap_handler;
sigemptyset(&act.sa_mask);
! #if defined (SYS_aix)
act.sa_flags = 0;
! #elif defined (SYS_rhapsody)
! act.sa_flags = SA_SIGINFO;
#else
act.sa_flags = SA_NODEFER;
#endif

@vicuna
Copy link
Author

vicuna commented Nov 7, 2002

Comment author: administrator

[problems with signal handling]

The bug is a bus error that stops the native version of the program.
The byte code version works fine.

This bug is now completely fixed in the current working version (3.06+17),
as far as MacOS X is concerned. It seems to exist also in some other
native ports, but we will get around to fixing them soon.

-- Damien

@vicuna
Copy link
Author

vicuna commented May 23, 2003

Comment author: administrator

Fixed on PowerPC by DD, 2002-11-7. Fix propagated to all other platforms
except
Power/AIX and Power/Linux.

@vicuna vicuna closed this as completed May 23, 2003
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant