~ chicken-core (chicken-5) 7866d8019e0a524b875e1b6e17743f4f382a0592
commit 7866d8019e0a524b875e1b6e17743f4f382a0592
Author: Evan Hanson <evhan@foldling.org>
AuthorDate: Sat Jun 11 13:05:37 2016 +1200
Commit: Peter Bex <peter@more-magic.net>
CommitDate: Fri Jun 17 18:06:19 2016 +0200
Clear fd list and suspend I/O threads on process-fork w/kill-other-threads
Previously, ##sys#kill-other-threads wouldn't clear the ##sys#fd-list,
leading to errors when unrecognized file descriptors were encountered
during scheduling. Additionally, it would set slots in random heap
locations near ##sys#fd-list (potentially leading to heap corruption)
since it incorrectly tried to suspend a list rather than a thread; the
fd list has a different format than the timeout-list, and its `cdr` is a
list of threads that must be each suspended individually.
Signed-off-by: Peter Bex <peter@more-magic.net>
diff --git a/scheduler.scm b/scheduler.scm
index 04f1fb26..73a39b09 100644
--- a/scheduler.scm
+++ b/scheduler.scm
@@ -603,7 +603,7 @@ EOF
;;; Kill all threads in fd-, io- and timeout-lists and assign one thread as the
-; new primordial one. Overrides "##sys#kill-all-threads" in library.scm.
+; new primordial one. Overrides "##sys#kill-other-threads" in library.scm.
(set! ##sys#kill-other-threads
(let ((exit exit))
@@ -618,12 +618,9 @@ EOF
(set! ready-queue-head (list primordial))
(set! ready-queue-tail ready-queue-head)
(suspend primordial) ; clear block-obj. and recipients
- (for-each
- (lambda (a) (suspend (cdr a)))
- ##sys#timeout-list)
+ (for-each (lambda (a) (suspend (cdr a))) ##sys#timeout-list)
+ (for-each (lambda (a) (for-each suspend (cdr a))) ##sys#fd-list)
(set! ##sys#timeout-list '())
- (for-each
- (lambda (a) (suspend (cdr a)))
- ##sys#fd-list)
+ (set! ##sys#fd-list '())
(thunk)
(exit)))))
Trap