Skip to content

Documentation of System.Mem.Weak should emphasize finalizers may be run earlier than expected

The problem is mentioned in addFinalizer, but not in mkWeak; moreover, the documentation of addFinalizer reads as if this is a problem specific to foreign pointers, which is not (and, unrelated, ForeignPtr# does not exist anymore).

It would be useful if the problem were highlighted in mkWeak, as it may introduce hard to find bugs in user code in cases where finalizers that are run too early cause problems. The behaviour of mkWeak is highly non-obvious.

Trac metadata
Trac field Value
Version 7.6.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Documentation
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information