mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 08:47:35 +02:00
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:
parent
71a551dd1d
commit
04d1655a6a
1 changed files with 3 additions and 0 deletions
|
@ -36,6 +36,9 @@
|
||||||
; TODO:
|
; TODO:
|
||||||
; current-thread - not sure how to look this up yet... may need a global list of running threads
|
; current-thread - not sure how to look this up yet... may need a global list of running threads
|
||||||
(define (thread-start! t)
|
(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))
|
(let* ((thunk (vector-ref t 1))
|
||||||
(mutator-id (Cyc-spawn-thread! thunk)))
|
(mutator-id (Cyc-spawn-thread! thunk)))
|
||||||
(vector-set! t 2 mutator-id)))
|
(vector-set! t 2 mutator-id)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue