From 04d1655a6a86a11364aef699fa33176531fd4976 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 14 Jan 2016 23:30:53 -0500 Subject: [PATCH] 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. --- srfi/18.sld | 3 +++ 1 file changed, 3 insertions(+) diff --git a/srfi/18.sld b/srfi/18.sld index 32676df0..bb75fee2 100644 --- a/srfi/18.sld +++ b/srfi/18.sld @@ -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)))