Chez Scheme: add test case for recent continuation GC repair

This commit is contained in:
Matthew Flatt 2020-08-19 09:04:21 -06:00
parent 2742962988
commit 1260f888c9
2 changed files with 26 additions and 0 deletions

View File

@ -4822,6 +4822,30 @@
;; Check that the GC update the reference to `key2` in `e`:
(eq? (car e) key2)))))))
;; ----------------------------------------
;; Check GC interaction with zero-sized contnuations - unlikely
;; to crash even if things are wrong, but it's worth a try
(let ()
(define (loop i)
(if (zero? i)
(call/cc (lambda (k) (k '())))
(let ([keeps (loop (sub1 i))])
(call/cc
(lambda (k)
(cons k keeps))))))
(with-interrupts-disabled
(collect 0)
(let ([keeps (filter (lambda (c)
(eqv? 0 (#%$continuation-stack-clength c)))
(loop 1000))])
;; The `keeps` list is probably non-empty
(collect 0 0)
(collect 0 0)
(keep-live keeps)
#t)))
;; ----------------------------------------
;; Check fasl:
(let ([s (gensym)])

View File

@ -12962,6 +12962,8 @@
,(if 1-shot?
`(immediate ,(constant opportunistic-1-shot-flag))
%ac0))
;; NB: clength will be 0 if we're reifying to hide a continuation link
;; where the attachments field is #f. Make sure the GC is ok with that.
(set! ,(%mref ,%xp ,(constant continuation-stack-clength-disp)) ,%ac0)
(set! ,(%tc-ref scheme-stack-size) ,(%inline - ,(%tc-ref scheme-stack-size) ,%ac0))
,(finish %xp)))]