From c81228f31eec2f023409e3c523b49ce5c1ca911f Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 1 Feb 2020 07:58:25 -0700 Subject: [PATCH] cs: more clearing of a terminated thread In particular, clear out the `suspend+resume-callbacks` field so that retaining the thread object does not retain those callbacks. --- racket/src/thread/thread.rkt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/racket/src/thread/thread.rkt b/racket/src/thread/thread.rkt index e72957d2df..49dec51779 100644 --- a/racket/src/thread/thread.rkt +++ b/racket/src/thread/thread.rkt @@ -129,9 +129,7 @@ [cpu-time #:mutable] ; accumulates CPU time in milliseconds - [future #:mutable] ; current would-be future - - [condition-wakeup #:mutable]) + [future #:mutable]) ; current would-be future #:authentic #:property host:prop:unsafe-authentic-override #t ; allow evt chaperone #:property prop:waiter @@ -203,8 +201,6 @@ 0 ; cpu-time #f ; future - - void ; condition-wakeup )) ((atomically (define cref (and c (custodian-register-thread c t remove-thread-custodian))) @@ -272,11 +268,14 @@ (thread-unscheduled-for-work-tracking! t)) (remove-from-sleeping-threads! t) (run-kill-callbacks! t) + (set-thread-suspend+resume-callbacks! t null) (when (thread-forward-break-to t) (do-break-thread (thread-forward-break-to t) 'break #f)) (for ([cr (in-list (thread-custodian-references t))]) (unsafe-custodian-unregister t cr)) - (set-thread-custodian-references! t null)) + (set-thread-custodian-references! t null) + (set-thread-mailbox! t #f) + (set-thread-mailbox-wakeup! t void)) ;; ---------------------------------------- ;; Thread termination