From 1a2c48cbd667667c49f0fa9bcccf5fac99297dc7 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 8 Oct 2019 21:59:15 -0600 Subject: [PATCH] cs & thread: fix place custodian unregister When a place terminates, it was directly accessing its parent's custodian. Prior support for cross-place uses of a hash table probably helped hide this problem previously. --- racket/src/thread/place.rkt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/racket/src/thread/place.rkt b/racket/src/thread/place.rkt index f38ad782a7..f5966b80ac 100644 --- a/racket/src/thread/place.rkt +++ b/racket/src/thread/place.rkt @@ -73,7 +73,6 @@ (host:mutex-acquire lock) (set-place-queued-result! new-place (if flush-failed? 1 (if (byte? v) v 0))) (place-has-activity! new-place) - (unsafe-custodian-unregister new-place (place-custodian-ref new-place)) (host:mutex-release lock)) ;; Switch to scheduler, so it can exit: (engine-block)) @@ -215,6 +214,10 @@ (set-place-host-thread! p #f) #t))) (log-place "reap" #:data (place-id p)))) + (define cref (place-custodian-ref p)) + (when cref + (unsafe-custodian-unregister p cref) + (set-place-custodian-ref! p #f)) result) ;; In atomic mode, callback from custodian: