diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-10-25 11:33:21 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-10-25 11:33:21 -0700 |
commit | 09f172c98f79f52a6e5c0e4ec87918a6e74aaccf (patch) | |
tree | badd09ef01db2cfd8ce77fd6e86ada747319aa8f /signal.c | |
parent | 329318ae4f9c180ed68ec484bb5e1acdcb3dec44 (diff) | |
download | txr-09f172c98f79f52a6e5c0e4ec87918a6e74aaccf.tar.gz txr-09f172c98f79f52a6e5c0e4ec87918a6e74aaccf.tar.bz2 txr-09f172c98f79f52a6e5c0e4ec87918a6e74aaccf.zip |
Stop using C library setjmp/longjmp.
TXR is moving to custom assembly-language routines.
This is mainly motivated by a very dubious thing done in the
GNU C Library setjmp and longjmp in the name of security.
Evidently, glibc's setjmp "mangles" certain pointer values
which are stored into the jmp_buf buffer. It's been that way
since 2005, evidently. This means that, firstly, all along,
the use of setjmp in gc.c to get registers into a buffer so
they can be scanned has not actually worked properly. More
importantly, this pointer mangling in setjmp and longjmp is
very hostile to a stack copying implementation of delimited
continuations. The reason is that continuations contain
jmp_buf buffers, which get relocated in the process of
capturing and reviving a continuation. Any pointers in a
jmp_buf which point into the captured stack segment have to be
fixed up to point into the relocated location. Mangled
pointers make this difficult, requiring hacks which are
specific to glibc and the machine architecture. We might as
well implement a clean, well-behaved setjmp and longjmp.
* Makefile (jmp.o): New object file.
(dbg/%.o, opt/%.o): New rules for .S prerequisites.
* args.c, arith.c, cadr.c, combi.c, cadr.c, combi.c, debug.c,
eval.c, filter.c, glob.c, hash.c, lib.c, match.c, parser.c,
rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c,
syslog.c, txr.c, unwind.c, utf8.c: Removed <setjmp.h>
include.
* gc.c: Switch to struct jmp and jmp_save, instead
of jmp_buf and setjmp.
* jmp.S: New source file.
* signal.h (struct jmp): New struct type.
(jmp_save, jmp_restore): New function declarations
denoting assembly language routines in jmp.S.
(extended_jmp_buf): Uses struct jmp instead of
setjmp.
(extended_setjmp): Use jmp_save instead of setjmp.
(extended_longjmp): Use jmp_restore instead of
longjmp.
Diffstat (limited to 'signal.c')
-rw-r--r-- | signal.c | 1 |
1 files changed, 0 insertions, 1 deletions
@@ -28,7 +28,6 @@ #include <stdlib.h> #include <string.h> #include <stdarg.h> -#include <setjmp.h> #include <errno.h> #include <wchar.h> #include <dirent.h> |