[GHC] #13148: Adding weak pointers to non-mutable unboxed values segfaults
GHC
ghc-devs at haskell.org
Wed Jan 18 15:24:14 UTC 2017
#13148: Adding weak pointers to non-mutable unboxed values segfaults
-------------------------------------+-------------------------------------
Reporter: mboes | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by mboes):
OK that makes sense. I was surprised that things worked with `MutVar#`
because I assumed it was also unboxed, but I see now that's not the case.
The types in `System.Mem.Weak` already preclude creating a weak pointer to
an unboxed value. But that of `mkWeakNoFinalizer#` is not precise enough
to rule that out. Is the rule that the first argument to this function is
valid iff it is of unlifted (primitive) type? If so, I think it would be
useful to document that there.
This exploration arose from the need to retrofit a single finalizer to a
codebase that makes extensive use of `Ptr` without having to switch to
`ForeignPtr` everywhere. The latter being more inconvenient, since it
can't appear in the type signature of foreign imports. I assume attaching
a finalizer to a `Ptr` runs the risk that the finalizer might fire too
early.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13148#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list