diff options
author | Marios Titas <geopoul@gmail.com> | 2014-12-10 04:17:22 -0600 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2014-12-10 04:20:08 -0600 |
commit | 7ca5bb090ff78141fbe275b058a9e35ee496bd58 (patch) | |
tree | 8c2c9f635746ad42f40e216f1fdea5ae4deea3ac /libraries/base/GHC/Conc/Signal.hs | |
parent | 4d1c452daf54e0ed04ee66d6d3ea9078924afd51 (diff) | |
download | haskell-7ca5bb090ff78141fbe275b058a9e35ee496bd58.tar.gz |
compiler: fix trac issue #9817
Summary:
When we call runHandlers, we must pass it a ForeignPtr. To ensure that
this happens, we introduce a wrapper that receives a plain Ptr and
converts it into a ForeignPtr. Then we adjust startSignalHandlers in
rts/posix/Signals.c to call the wrapper instead of calling runHandlers
directly.
Reviewers: hvr, austin, rwbarton, simonmar
Reviewed By: austin, simonmar
Subscribers: simonmar, thomie, carter
Differential Revision: https://phabricator.haskell.org/D515
GHC Trac Issues: #9817
Diffstat (limited to 'libraries/base/GHC/Conc/Signal.hs')
-rw-r--r-- | libraries/base/GHC/Conc/Signal.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libraries/base/GHC/Conc/Signal.hs b/libraries/base/GHC/Conc/Signal.hs index 3f5eacb572..4afccf2496 100644 --- a/libraries/base/GHC/Conc/Signal.hs +++ b/libraries/base/GHC/Conc/Signal.hs @@ -6,15 +6,17 @@ module GHC.Conc.Signal , HandlerFun , setHandler , runHandlers + , runHandlersPtr ) where import Control.Concurrent.MVar (MVar, newMVar, withMVar) import Data.Dynamic (Dynamic) import Foreign.C.Types (CInt) -import Foreign.ForeignPtr (ForeignPtr) +import Foreign.ForeignPtr (ForeignPtr, newForeignPtr) import Foreign.StablePtr (castPtrToStablePtr, castStablePtrToPtr, deRefStablePtr, freeStablePtr, newStablePtr) import Foreign.Ptr (Ptr, castPtr) +import Foreign.Marshal.Alloc (finalizerFree) import GHC.Arr (inRange) import GHC.Base import GHC.Conc.Sync (forkIO) @@ -70,6 +72,13 @@ runHandlers p_info sig = do Just (f,_) -> do _ <- forkIO (f p_info) return () +-- It is our responsibility to free the memory buffer, so we create a +-- foreignPtr. +runHandlersPtr :: Ptr Word8 -> Signal -> IO () +runHandlersPtr p s = do + fp <- newForeignPtr finalizerFree p + runHandlers fp s + -- Machinery needed to ensure that we only have one copy of certain -- CAFs in this module even when the base package is present twice, as -- it is when base is dynamically loaded into GHCi. The RTS keeps |