~ chicken-core (chicken-5) 73b7b3dc01f85fdfa87d5b0949eb2775b7e76e39
commit 73b7b3dc01f85fdfa87d5b0949eb2775b7e76e39 Author: Peter Bex <peter@more-magic.net> AuthorDate: Sat Sep 24 11:41:41 2016 +0200 Commit: Evan Hanson <evhan@foldling.org> CommitDate: Mon Sep 26 21:28:20 2016 +1300 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 Signed-off-by: Evan Hanson <evhan@foldling.org> diff --git a/NEWS b/NEWS index ebe102c7..658e61e9 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 cbe58953..24799860 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 #\})))Trap