Incompatible change in Mach exception handler behavior on Mac OS X 10.6
Tuesday, March 23, 2010
On Mac OS X, Factor uses Mach exceptions rather than Unix signals to receive notifications of illegal memory accesses and arithmetic exceptions from the operating system. This is used to catch datastack underflows, division by zero, and the like. The code implementing this can be found in vm/mach_signal.c in the Factor repository. This file is based on code from the GNU libsigsegv project, with special permission to use it under a BSD license instead of the restrictive GPL.
It seems that as of Mac OS X 10.6, exceptions raised by child processes
are now reported to the parent if the parent has an exception handler
thread. This caused a problem in Factor if a child process crashed with
an access violation; Factor would think the access violation occurred in
Factor code, and die with an assertion failure when attempting to map
the thread ID back into a Factor VM object. It seems the simplest way is
to add the following clause to the catch_exception_raise()
function:
if(task != mach_task_self()) return KERN_FAILURE;
This fix should be applicable to the original libsigsegv
code as well,
along with other projects, such as CLisp, that use this library.