summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-03-04 06:06:07 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-03-04 06:06:07 -0800
commit337999558d07be88676bf31fd201ebde389a54fa (patch)
tree6acc97847d688492228bc471cb9ab469ae13047b
parentccf85499a313ba6a8556f517ffad06c7f80f9687 (diff)
downloadtxr-337999558d07be88676bf31fd201ebde389a54fa.tar.gz
txr-337999558d07be88676bf31fd201ebde389a54fa.tar.bz2
txr-337999558d07be88676bf31fd201ebde389a54fa.zip
compiler: frame depth bug in load-time.
* share/txr/stdlib/compiler.tl (compile-in-toplevel): This macro must not save and restore the nlev variable of the compiler. The nlev variable is a maximum: it measures the maximum environment depth, establishing the depth of the display needed when executing the code of the resulting VM description. By saving and restoring this variable around the compilation of a load-time form, we cause the load-time form's contribution to the maximum to be ignored. If the load-time form perpetrates nesting that is deeper than other code, it will execute with an under-sized display, causing an assertion crash or corruption.
-rw-r--r--share/txr/stdlib/compiler.tl9
1 files changed, 3 insertions, 6 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index d3b1a44e..de5788c2 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -192,21 +192,18 @@
(with-gensyms (saved-tregs saved-treg-cntr saved-nlev saved-discards)
^(let* ((,saved-tregs (qref ,me tregs))
(,saved-treg-cntr (qref ,me treg-cntr))
- (,saved-discards (qref ,me discards))
- (,saved-nlev (qref ,me nlev)))
+ (,saved-discards (qref ,me discards)))
(unwind-protect
(progn
(set (qref ,me tregs) nil
(qref ,me treg-cntr) 2
- (qref ,me discards) nil
- (qref ,me nlev) 2)
+ (qref ,me discards) nil)
(prog1
(progn ,*body)
(qref ,me (check-treg-leak))))
(set (qref ,me tregs) ,saved-tregs
(qref ,me treg-cntr) ,saved-treg-cntr
- (qref ,me discards) ,saved-discards
- (qref ,me nlev) ,saved-nlev)))))
+ (qref ,me discards) ,saved-discards)))))
(defmacro compile-with-fresh-tregs (me . body)
(with-gensyms (saved-tregs saved-treg-cntr saved-discards)