From ac5d6d66c18827e7d99de3015fbf6a64311bdeaf Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Fri, 12 Dec 2008 17:25:03 +0000 Subject: [PATCH] make call-in-nested-thread avoid potential break problem svn: r12792 --- collects/scheme/sandbox.ss | 40 +++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/collects/scheme/sandbox.ss b/collects/scheme/sandbox.ss index a480fa44b9..fcef51338a 100644 --- a/collects/scheme/sandbox.ss +++ b/collects/scheme/sandbox.ss @@ -230,24 +230,28 @@ [shutdown (lambda () (custodian-shutdown-all (current-custodian)))]) (let* ([p #f] [c (make-custodian (current-custodian))] - [b (make-custodian-box c #t)]) - (with-handlers ([(lambda (_) (not p)) - ;; if the after thunk was not called, then this error is - ;; about the thread dying unnaturally, so propagate - ;; whatever it did - (lambda (_) ((if (custodian-box-value b) kill shutdown)))]) - (dynamic-wind void - (lambda () - (parameterize ([current-custodian c]) - (call-in-nested-thread - (lambda () - (dynamic-wind void thunk - ;; this should always be called unless the thread is killed or - ;; the custodian is shutdown, distinguish the two cases - ;; through the above box - (lambda () - (set! p (current-preserved-thread-cell-values)))))))) - (lambda () (when p (current-preserved-thread-cell-values p))))))) + [b (make-custodian-box c #t)] + [break? (break-enabled)]) + (parameterize-break #f + (with-handlers ([(lambda (_) (not p)) + ;; if the after thunk was not called, then this error is + ;; about the thread dying unnaturally, so propagate + ;; whatever it did + (lambda (_) + ((if (custodian-box-value b) kill shutdown)))]) + (dynamic-wind void + (lambda () + (parameterize ([current-custodian c]) + (call-in-nested-thread + (lambda () + (break-enabled break?) + (dynamic-wind void thunk + ;; this should always be called unless the thread is killed + ;; or the custodian is shutdown, distinguish the two cases + ;; through the above box + (lambda () + (set! p (current-preserved-thread-cell-values)))))))) + (lambda () (when p (current-preserved-thread-cell-values p)))))))) (define (call-with-limits sec mb thunk) ;; note that when the thread is killed after using too much memory or time,