mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 09:10:22 +02:00
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.
This commit is contained in:
parent
67c4505e7a
commit
7e4760e413
9 changed files with 110 additions and 33 deletions
|
@ -6,12 +6,15 @@ GUILE_VM = $(top_builddir)/src/guile-vm
|
|||
vm_test_files = \
|
||||
t-basic-contructs.scm \
|
||||
t-global-bindings.scm \
|
||||
t-catch.scm \
|
||||
t-closure.scm \
|
||||
t-closure2.scm \
|
||||
t-closure3.scm \
|
||||
t-do-loop.scm \
|
||||
t-macros.scm \
|
||||
t-macros2.scm \
|
||||
t-map.scm \
|
||||
t-or.scm \
|
||||
t-proc-with-setter.scm \
|
||||
t-values.scm \
|
||||
t-records.scm \
|
||||
|
|
10
testsuite/t-catch.scm
Normal file
10
testsuite/t-catch.scm
Normal file
|
@ -0,0 +1,10 @@
|
|||
;; Test that nonlocal exits of the VM work.
|
||||
|
||||
(begin
|
||||
(define (foo thunk)
|
||||
(catch #t thunk (lambda args args)))
|
||||
(foo
|
||||
(lambda ()
|
||||
(let ((a 'one))
|
||||
(1+ a)))))
|
||||
|
10
testsuite/t-map.scm
Normal file
10
testsuite/t-map.scm
Normal file
|
@ -0,0 +1,10 @@
|
|||
; Currently, map is a C function, so this is a way of testing that the
|
||||
; VM is reentrant.
|
||||
|
||||
(begin
|
||||
|
||||
(define (square x)
|
||||
(* x x))
|
||||
|
||||
(map (lambda (x) (square x))
|
||||
'(1 2 3)))
|
27
testsuite/t-or.scm
Normal file
27
testsuite/t-or.scm
Normal file
|
@ -0,0 +1,27 @@
|
|||
;; all the different permutations of or
|
||||
(list
|
||||
;; not in tail position, no args
|
||||
(or)
|
||||
;; not in tail position, one arg
|
||||
(or 'what)
|
||||
(or #f)
|
||||
;; not in tail position, two arg
|
||||
(or 'what 'where)
|
||||
(or #f 'where)
|
||||
(or #f #f)
|
||||
(or 'what #f)
|
||||
;; in tail position (within the lambdas)
|
||||
((lambda ()
|
||||
(or)))
|
||||
((lambda ()
|
||||
(or 'what)))
|
||||
((lambda ()
|
||||
(or #f)))
|
||||
((lambda ()
|
||||
(or 'what 'where)))
|
||||
((lambda ()
|
||||
(or #f 'where)))
|
||||
((lambda ()
|
||||
(or #f #f)))
|
||||
((lambda ()
|
||||
(or 'what #f))))
|
Loading…
Add table
Add a link
Reference in a new issue