cs & thread: fix use of custodian weak reference

Commit 77023aeaba made the reference from a custodian-managed
value to the custodian weak, and that could cause a crash in
certain shutdown cases.

Relevant to #2867
This commit is contained in:
Matthew Flatt 2019-10-23 17:27:29 -06:00
parent 79c27ece6f
commit 487277ad02

View File

@ -158,13 +158,14 @@
(when cref
(atomically
(define c (custodian-reference->custodian cref))
(unless (custodian-shut-down? c)
(hash-remove! (custodian-children c) obj))
(host:disable-interrupts)
(define gc-roots (custodian-gc-roots c))
(when gc-roots
(hash-remove! gc-roots obj))
(host:enable-interrupts))
(when c
(unless (custodian-shut-down? c)
(hash-remove! (custodian-children c) obj))
(host:disable-interrupts)
(define gc-roots (custodian-gc-roots c))
(when gc-roots
(hash-remove! gc-roots obj))
(host:enable-interrupts)))
(void)))
;; Called by scheduler (so atomic) when `c` is unreachable