avoid race on places and initialization for eval

Force visits on internal Chez Scheme modules before starting a place,
so that there won't be a race among places to visit the modules.
This commit is contained in:
Matthew Flatt 2020-08-07 07:19:09 -06:00
parent 5faf14c45b
commit 776b69e399
3 changed files with 25 additions and 0 deletions

View File

@ -808,6 +808,25 @@
(set-make-place-ports+fds! make-place-ports+fds)
(set-prepare-for-place!
(lambda ()
;; Force visit of modules to make sure that we don't end up
;; with a race later by trying to visit the module in a place:
(call-with-system-wind
(lambda ()
(for-each (lambda (lib)
(#%$visit-library lib '() #f))
'((chezscheme)
(rumble)
(thread)
(io)
(regexp)
(schemify)
(linklet)
(expander)))
;; Only need to visit once (although multiple time is ok)
(set-prepare-for-place! void)))))
(set-start-place!
(lambda (pch mod sym in out err cust plumber)
(io-place-init! in out err cust plumber)

View File

@ -602,6 +602,7 @@
unsafe-extfl->fx unsafe-fx->extfl unsafe-extflsqrt
unsafe-extflvector-length unsafe-extflvector-ref unsafe-extflvector-set!
set-prepare-for-place! ; not exported to Racket
set-start-place! ; not exported to Racket
set-destroy-place! ; not exported to Racket
fork-place ; not exported to Racket

View File

@ -79,6 +79,7 @@
[(threaded?)
(define (place-enabled?) #t)
(define (fork-place thunk finish-proc)
(do-prepare-for-place)
(fork-thread (lambda ()
(init-virtual-registers)
(place-registers (vector-copy place-register-inits))
@ -102,6 +103,10 @@
(define (fork-place thunk finish-proc) #f)
(define (current-place-roots) '())])
(define do-prepare-for-place void)
(define (set-prepare-for-place! proc)
(set! do-prepare-for-place proc))
(define do-start-place void)
(define (set-start-place! proc)
(set! do-start-place proc))