[Ecls-list] More thoughts on signals, stack overflows, etc

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Tue Oct 7 22:11:05 UTC 2008


On Tue, Oct 7, 2008 at 10:17 AM, Juan Jose Garcia-Ripoll
<juanjose.garciaripoll at googlemail.com> wrote:
> The idea would be to allocate a separate memory page for the lisp
> environment using mmap. When a signal comes in, we store the relevant
> information about the signal into the environment and this page is
> protected from writing using mprotect(). Then the signal handler
> immediately returns. Whenever the program writes to the lisp
> environment (and this happens quite often), if there was a pending
> interrupt, our handler will be reentered and we will be able to
> execute whatever code we want, because this time the signal comes from
> a "safe" place.

The GIT repository has a new branch called new_signals that implements
this proof of concept. The source code is not complete because the
interrupt delay mechanism is only used by read-char, but it gives you
an idea how it should work (see below for debug messages). It also
seems to work with Ubuntu/x64 and the generational garbage collector,
which previously it did not.

The new code also expects an outermost handler for unrecoverable stack
overflows. I still have to precise what is the API for doing this so
that it also works for embedded ECL. Here the idea is to completely
avoid any lisp code from executing in the alternative stack. When the
machine stack really overflows, we undo as many calls as neeeded until
a place that the user marked as a catch point for stack overflows and
SIGSEGV.

Help is welcome on both fronts.

Juanjo

$ ecl -norc
ECL (Embeddable Common-Lisp) 8.10.0 (CVS 2008-07-12 18:54)
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.  Top level.
> (read-char)
^CNon evil handler
Postponing signal 2
SIGSEGV Handler: 2b37d0
SIGBUS Handler: 2b37d0
Protecting 38000
Clearing file errors
Entering sigsegv_handler for address 0x38000
Unprotecting 38000
Console interrupt
Broken at SI:BYTECODES.Available restarts:
1. (CONTINUE) Continues execution.
Broken at SI:BYTECODES.
>> :q
Top level.
>

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28009 (Spain)
http://juanjose.garciaripoll.googlepages.com


More information about the ecl-devel mailing list