From 7b76d0cbf56d54fc19f16b6aeee5600cb58270b0 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Sat, 24 Sep 2016 11:41:41 +0200 Subject: [PATCH] Copy temp arg values back into argvector on loop This would prevent the procedure from starting from scratch after GC. With this change, we continue the calculation, as it should be. Fixes #1317 --- NEWS | 4 ++++ c-backend.scm | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ebe102c..658e61e 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ 4.11.2 +- Compiler: + - Fixed incorrect argvector restoration after GC in directly + recursive functions (#1317). + 4.11.1 - Security fixes diff --git a/c-backend.scm b/c-backend.scm index cbe5895..2479986 100644 --- a/c-backend.scm +++ b/c-backend.scm @@ -845,6 +845,11 @@ (else (gen #\{))))) (cond ((and (not (eq? 'toplevel id)) (not direct)) + (when (and looping (not customizable)) + ;; Loop will update t_n copy of av[n]; refresh av. + (do ((i 0 (add1 i))) + ((>= i n)) + (gen #t "av[" i "]=t" i ";"))) (cond (rest (gen #t "C_save_and_reclaim((void*)" id ",c,av);}" #t "a=C_alloc((c-" n ")*C_SIZEOF_PAIR+" demand ");") @@ -859,7 +864,7 @@ (apply gen arglist) (gen ");}")) (else - (gen "C_save_and_reclaim((void *)" id #\, n ",av);}"))) + (gen #t "C_save_and_reclaim((void *)" id #\, n ",av);}"))) (when (> demand 0) (gen #t "a=C_alloc(" demand ");"))))) (else (gen #\}))) -- 2.1.4