Note last-statistic early in signal-gc-events.
authorMatt Birkholz <puck@birchwood-abbey.net>
Fri, 11 Dec 2015 17:28:50 +0000 (10:28 -0700)
committerMatt Birkholz <puck@birchwood-abbey.net>
Sun, 3 Jan 2016 20:06:12 +0000 (13:06 -0700)
The signaled thread events may run whenever, perhaps after
last-statistic is changed.  Ensure all the thread events get the same
statistic -- the last-statistic when the events were sent.

src/runtime/gcnote.scm

index 30c1dd44a4bec4c8b07762364e4cd6ed74424c8d..9053466a52d64102e049c07397c9d0e64bbb5941 100644 (file)
@@ -108,18 +108,19 @@ USA.
     (and entry (weak-cdr entry))))
 
 (define (signal-gc-events)
-  (for-each
-    (lambda (entry)
-      (let ((thread (weak-car entry))
-           (event (weak-cdr entry)))
-       (if (and thread event)
-           (signal-thread-event
-               thread
-             (named-lambda (gc-event)
-               (abort-if-heap-low (gc-statistic/heap-left last-statistic))
-               (event last-statistic))
-             #t))))
-    gc-events))
+  (let ((statistic last-statistic))
+    (for-each
+      (lambda (entry)
+       (let ((thread (weak-car entry))
+             (event (weak-cdr entry)))
+         (if (and thread event)
+             (signal-thread-event
+                 thread
+               (named-lambda (gc-event)
+                 (abort-if-heap-low (gc-statistic/heap-left statistic))
+                 (event statistic))
+               #t))))
+      gc-events)))
 
 (define (weak-assq obj alist)
   (let loop ((alist alist))