From 337999558d07be88676bf31fd201ebde389a54fa Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 4 Mar 2021 06:06:07 -0800 Subject: 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. --- share/txr/stdlib/compiler.tl | 9 +++------ 1 file 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) -- cgit v1.2.3