Prevent passing stack objects to a thread's closure

Modified thread-start! to initiate a GC prior to running the thread, in case thunk contains any closures on the "parent" thread's stack. Otherwise when the parent thread goes to collect them, the contents will be corrupted when the spawned thread attempts to access them.
This commit is contained in:
Justin Ethier 2016-01-14 23:30:53 -05:00
parent 71a551dd1d
commit 04d1655a6a

View file

@ -36,6 +36,9 @@
; TODO:
; current-thread - not sure how to look this up yet... may need a global list of running threads
(define (thread-start! t)
;; Initiate a GC prior to running the thread, in case
;; t contains any closures on the "parent" thread's stack
(Cyc-minor-gc)
(let* ((thunk (vector-ref t 1))
(mutator-id (Cyc-spawn-thread! thunk)))
(vector-set! t 2 mutator-id)))