-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a potential space leak related to HasCallStack quirks (#279)
The following program: ```haskell import Control.Monad import Effectful import Effectful.Concurrent import Effectful.Concurrent.MVar import Effectful.Reader.Dynamic import Effectful.Provider import Effectful.Provider.List f :: Concurrent :> es => MVar () -> Int -> Eff es () f var = \case 0 -> putMVar var () n -> void $ forkIO $ f var (n - 1) main :: IO () main = runEff . runReader () . runProvider_ (\() -> runReader ()) . runProviderList_ @'[Reader ()] (\() -> runReader ()) . runConcurrent $ do var <- newEmptyMVar f var 10000000 takeMVar var ``` used to leak memory because GHC attaches a new stack frame to fields with HasCallStack constraints on every record reconstruction. Here it means every relinking, so if the relinks are nested, call stacks atached to these fields will keep growing. The workaround is to wrap these fields in newtypes, see https://gitlab.haskell.org/ghc/ghc/-/issues/25520 for more information.
- Loading branch information
Showing
6 changed files
with
119 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.