chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] Clear fd list and suspend I/O threads on proce


From: Evan Hanson
Subject: [Chicken-hackers] [PATCH] Clear fd list and suspend I/O threads on process-fork w/kill-other-threads
Date: Sat, 11 Jun 2016 13:05:37 +1200

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.
---
 scheduler.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/scheduler.scm b/scheduler.scm
index 4f9f8d8..9b1f549 100644
--- a/scheduler.scm
+++ b/scheduler.scm
@@ -590,12 +590,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)))))
-- 
2.8.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]