@@ -3217,8 +3217,12 @@ runIORefFinalizer ref = liftIO $ do
3217 case res of
3217 case res of
3218 Nothing -> return ()
3218 Nothing -> return ()
3219 Just action -> do
3219 Just action -> do
3220+ -- if an async exception comes after writing 'Nothing' then the
3221+ -- finalizing action will never be run. We need to do this
3222+ -- atomically wrt async exceptions.
3220− writeIORef ref Nothing
3224+ writeIORef ref Nothing
3223-- | Deactivate the finalizer stored in an IORef without running it.
3227-- | Deactivate the finalizer stored in an IORef without running it.