[GHC] #12547: Concurrent.ForeignPtr needs to access a C-ForeignPtr, but this is already gone
GHC
ghc-devs at haskell.org
Sun Sep 4 06:34:40 UTC 2016
#12547: Concurrent.ForeignPtr needs to access a C-ForeignPtr, but this is already
gone
-------------------------------------+-------------------------------------
Reporter: Lemming | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Runtime System | 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 Lemming):
Replying to [comment:1 simonmar]:
> Currently all `ForeignPtrs` that are unreachable get finalized at the
same time. This is how it's intended to work.
>
> We *could* refine it so that a finalizer from a `Concurrent.ForeignPtr`
can keep a C `ForeignPtr` alive. It would mean processing the two kinds
of weak pointers in separate batches (and possibly keeping them in
separate lists, I'm not sure).
You gave me privately the tip to use `StablePtr`. So I added a
`freeStablePtr` after `withForeignPtr`. This works nicely!
Thus I think it is enough to add a warning to `touchForeignPtr` and
`withForeignPtr` that they have no effect in a concurrent finalizer and
that you should consider `StablePtr` instead.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12547#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list