summaryrefslogtreecommitdiff
path: root/src/vm_system.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2008-08-11 18:35:58 +0200
committerAndy Wingo <wingo@pobox.com>2008-08-11 18:35:58 +0200
commit7e4760e4133160e24cc15dba17cdeac3040eb080 (patch)
tree088db6283f78a51781bcd1ee4570bc7ca852c4d5 /src/vm_system.c
parent67c4505e7a1002d8bbb395d3d4d79e77250f737e (diff)
downloadguile-7e4760e4133160e24cc15dba17cdeac3040eb080.tar.gz
fix bug in compilation of `and' and `or'; more robust underflow detection.
* module/system/il/compile.scm (codegen): Rewrite handling of `and' and `or' ghil compilation, because it was broken if drop was #t. Tricky bug, this one! Took me days to track down! * module/system/repl/repl.scm: Export call-with-backtrace, which probably should go in some other file. * src/vm.c (scm_vm_save_stack): Handle the fp==0 case for errors before we have a frame. * src/vm_engine.h (NEW_FRAME, FREE_FRAME): Stricter underflow checking, raising the stack base to the return address, in an attempt to prevent inadvertant stack smashing (the symptom of the and/or miscompilation bug). (CHECK_IP): A check that the current IP is within the bounds of the current program. Not normally compiled in. Perhaps it should be? * src/vm_system.c (halt): Set vp->ip to NULL. Paranoia, I know. (return): Call CHECK_IP(), if such a thing is compiled in. * testsuite/Makefile.am (vm_test_files): * testsuite/t-catch.scm: * testsuite/t-map.scm: * testsuite/t-or.scm: New tests.
Diffstat (limited to 'src/vm_system.c')
-rw-r--r--src/vm_system.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/vm_system.c b/src/vm_system.c
index c45126f04..179208e0a 100644
--- a/src/vm_system.c
+++ b/src/vm_system.c
@@ -60,6 +60,7 @@ VM_DEFINE_INSTRUCTION (halt, "halt", 0, 0, 0)
POP (ret);
FREE_FRAME ();
SYNC_ALL ();
+ vp->ip = NULL;
scm_dynwind_end ();
return ret;
}
@@ -657,6 +658,7 @@ VM_DEFINE_INSTRUCTION (return, "return", 0, 0, 1)
program = SCM_FRAME_PROGRAM (fp);
CACHE_PROGRAM ();
CACHE_EXTERNAL ();
+ CHECK_IP ();
NEXT;
}