diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-03-04 06:06:07 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-03-04 06:06:07 -0800 |
commit | 12bd13a955936fe1ee30bb4f2a202ecadd2cce9e (patch) | |
tree | 6acc97847d688492228bc471cb9ab469ae13047b | |
parent | f3caaf8efd66511eeff194c198e59308c27de54d (diff) | |
download | txr-12bd13a955936fe1ee30bb4f2a202ecadd2cce9e.tar.gz txr-12bd13a955936fe1ee30bb4f2a202ecadd2cce9e.tar.bz2 txr-12bd13a955936fe1ee30bb4f2a202ecadd2cce9e.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.tl | 9 |
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) |