From 1d8791c7c47a860cd0221949d4191b53c85ef245 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 3 Aug 2012 11:06:36 -0600 Subject: [PATCH] ffi/unsafe: show errors from a finalizer Previously, an error from a finalizer would disappear and kill of the finalizer thread. Now the error is logged and the thread continues. --- collects/ffi/unsafe.rkt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/collects/ffi/unsafe.rkt b/collects/ffi/unsafe.rkt index 9e35e33211..d828a24bcb 100644 --- a/collects/ffi/unsafe.rkt +++ b/collects/ffi/unsafe.rkt @@ -1651,10 +1651,26 @@ _pointer ; break_cell _scheme ; custodian _int ; suspend-to-kill? - -> _scheme))]) + -> _scheme))] + [logger (current-logger)] + [cweh #f]) ; <- avoids a reference to a module-level binding + (set! cweh call-with-exception-handler) (set! killer-thread (thread/details (lambda () - (let loop () (will-execute killer-executor) (loop))) + (let retry-loop () + (call-with-continuation-prompt + (lambda () + (cweh + (lambda (exn) + (log-message logger + (if (exn? exn) + (exn-message exn) + (format "~s" exn)) + #f) + (abort-current-continuation void)) + (lambda () + (let loop () (will-execute killer-executor) (loop)))))) + (retry-loop))) min-config no-cells #f ; default break cell