From 6cfdca9f014895a9962e1d077719a96842383000 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Mon, 18 Jan 2021 14:44:28 +0000 Subject: Correct documentation in System.Mem.Weak [ci skip] Since #13167 is closed, exceptions thrown in finalizers are ignored and doesn't affect other finalizers in the same batch. This MR updates the documentation in System.Mem.Weak to reflect that. --- libraries/base/System/Mem/Weak.hs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/libraries/base/System/Mem/Weak.hs b/libraries/base/System/Mem/Weak.hs index 8d21eb59d9..654f18f655 100644 --- a/libraries/base/System/Mem/Weak.hs +++ b/libraries/base/System/Mem/Weak.hs @@ -147,22 +147,16 @@ A heap object is /reachable/ if: {- $notes A finalizer is not always called after its weak pointer\'s object becomes -unreachable. There are two situations that can cause this: - - * If the object becomes unreachable right before the program exits, - then GC may not be performed. Finalizers run during GC, so finalizers - associated with the object do not run if GC does not happen. - - * If a finalizer throws an exception, subsequent finalizers that had - been queued to run after it do not get run. This behavior may change - in a future release. See issue - on the issue tracker. Writing a finalizer that throws exceptions is - discouraged. - -Other than these two caveats, users can always expect that a finalizer -will be run after its weak pointer\'s object becomes unreachable. However, -the second caveat means that users need to trust that all of their -transitive dependencies do not throw exceptions in finalizers, since -any finalizers can end up queued together. +unreachable. If the object becomes unreachable right before the program exits, +then GC may not be performed. Finalizers run during GC, so finalizers associated +with the object do not run if GC does not happen. + +Other than the above caveat, users can always expect that a finalizer will be +run after its weak pointer\'s object becomes unreachable. + +If a finalizer throws an exception, the exception is silently caught without +notice. See the commit of issue + for details. Writing a +finalizer that throws exceptions is discouraged. -} -- cgit v1.2.1