summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-18 20:55:25 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-18 20:55:25 -0700
commit3a9346cb299151cce4d46ebcf20c0f4bb76c697a (patch)
tree2e17ef93df12f766937f2f9d95747db18bdde023 /share
parentd52dd126b35bfa0f6139a2dd4fb547493ed447bd (diff)
downloadtxr-3a9346cb299151cce4d46ebcf20c0f4bb76c697a.tar.gz
txr-3a9346cb299151cce4d46ebcf20c0f4bb76c697a.tar.bz2
txr-3a9346cb299151cce4d46ebcf20c0f4bb76c697a.zip
compiler: bugfix: miscompiled unwind-protect.
* share/txr/stdlib/compiler.tl (compiler comp-unwind-protect): The protected code must terminate with an end instruction. It cannot just branch to the skip label because then we keep executing the following unprotected code still under the unwind protect. How it works is that the protected code ends with end. Then the cleanup fragment at the cleanup offset is executed, also terminating with an end (that one we have in place). We don't need the skip label because the instruction pointer advances after executing the end instruction after the cleanup fragment.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/compiler.tl8
1 files changed, 3 insertions, 5 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index 5d68e0f5..1ac0c3af 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -518,8 +518,7 @@
(let* ((treg me.(alloc-treg))
(pfrag me.(compile oreg env prot-form))
(cfrag me.(comp-progn treg env cleanup-body))
- (lclean (gensym "l"))
- (lskip (gensym "l")))
+ (lclean (gensym "l")))
me.(free-treg treg)
(cond
((null pfrag.code)
@@ -531,11 +530,10 @@
(t (new (frag pfrag.oreg
^((uwprot ,lclean)
,*pfrag.code
- (jmp ,lskip)
+ (end nil)
,lclean
,*cfrag.code
- (end nil)
- ,lskip)
+ (end nil))
(uni pfrag.fvars pfrag.fvars)
(uni cfrag.fvars cfrag.fvars))))))))