[CM] Handling an accidental forever loop

bil at ccrma.Stanford.EDU bil at ccrma.Stanford.EDU
Wed Jan 27 06:31:01 PST 2021


You can set (*s7* 'max-stack-size) which will raise an
error if the stack gets beyond that size.  Tail recursion
does not affect the stack, so the stack-max-size only
catches "normal" infinite recursion.  I don't know the
context, but in nrepl I trap SIGINT (control-C) and
raise an error in the interrupt handler -- look for
set_sigint_handler and related code in nrepl.c.  This
is then enabled during s7_eval_string in nrepl.scm.
I just noticed (of course!) that it only works once --
not sure why you can't interrupt successive expressions.
Snd (and maybe Grace) use s7's begin_hook to interrupt
computation, but that slows down everything (it is
polling the begin_hook and calling a function each time)
and might not work in loops that the optimizer has
so tightly optimized that no scheme-level body exists.



More information about the Cmdist mailing list