Closed kirelagin closed 1 year ago
I doubt it's actually that hard to get unsafeDupablePerformIO
to be interrupted, though it probably doesn't happen very often for small computations. I suspect the right answer is to document (at least internally) that all instances used must be unsafeDupablePerformIO
-safe, and point out some of the important ones that are.
In a number of places
cryptonite
usesalloc
/allocRet
frommemory
withinunsafeDupablePerformIO
.What makes
unsafeDupablePerformIO
different fromunsafePerformIO
is that the former can be interrupted silently, without raising an exception and without a cleanup. At the same time,allocRet
is a class method and it does not enforce any particular allocation strategy, so my concern here is that the memory can leak.To be clear, this issue is purely theoretic, since in current versions of GHC it seems to be extremely hard to get
unsafeDupablePerformIO
to interrupt and also sinceByteArray
instances (e.g. the ones inmemory
) will probably only allocate GC memory, so it will get reclaimed even if interrupted.