From df40cc7ba9c6a5e165146d4dedc960ca3d62d3ff Mon Sep 17 00:00:00 2001 From: Sam Caldwell Date: Fri, 24 Feb 2017 14:00:33 -0500 Subject: [PATCH] fix race in trace testing --- racket/syndicate/little-actors/core.rkt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/racket/syndicate/little-actors/core.rkt b/racket/syndicate/little-actors/core.rkt index 793705f..1b5fc20 100644 --- a/racket/syndicate/little-actors/core.rkt +++ b/racket/syndicate/little-actors/core.rkt @@ -674,7 +674,8 @@ ;; Actor AsyncChannel Program -> Boolean ;; trace-actor is the first actor spawned inside the program's ground dataspace -;; chan is a channel used by the trace-actor to signal a completed trace +;; chan is a channel used by the trace-actor to signal a completed trace, by +;; sending a non-falsey value (define (run-with-tracing trace-actor chan p #:timeout [timeout never-evt]) (define boot-actions (for/list ([boot (in-list p)]) @@ -688,7 +689,13 @@ (sync (handle-evt chan (lambda (val) #t)) (handle-evt syndicate-thread - (lambda (val) #f)))) + (lambda (val) + ;; it's possible one of the final events in the + ;; dataspace resulted in an accepting trace and the + ;; thread ended at the same time, so the scheduler + ;; picked this event. Double check the channel for this + ;; case. + (async-channel-try-get chan))))) (kill-thread syndicate-thread) result)