Ensure that signal handlers see the C stack, not the Scheme stack.
Do this by wrapping all the signal handlers in stubs that call an
assembly hook to make the stack pointer point into the C stack rather
than the Scheme stack if necessary. To indicate that this is not
necessary, define SIGNAL_HANDLERS_CAN_USE_SCHEME_STACK. For now, I'm
leaving that undefined by default, because it is the safer option.
This solves a problem on operating systems such as NetBSD that store
the current pthread identifier in the stack pointer. When Scheme's
signal handler calls routines that are pthread cancellation points,
such as waitpid, they try to find the current pthread identifier in a
stack pointer that points off into oblivion (into Scheme's stack) and
promptly crash -- or, worse, trigger SIGSEGV, to be handled by a
signal handler while the stack pointer still points into Scheme's
stack, with the same problem.
I am told that this will be fixed in NetBSD 6 (since it interferes
not just with Scheme but also with sigaltstack, makecontext, and
anything else that wants to mess with the stack pointer), but only on
i386 and amd64 for certain, and in any case, this workaround will
work on any other systems that try to use the same trick to store the
current pthread identifier, of which I believe there may be several.
(E.g., older versions of GNU/Linux with LinuxThreads.)