Delimited continuation primops panic with `-prof`
Summary
control0#
(from !7942 (merged)) seems unable to correctly find prompt#
frames with profiling enabled.
Steps to reproduce
Consider this file:
{-# LANGUAGE MagicHash, UnboxedTuples #-}
module Main where
import GHC.Exts
import GHC.IO
import Data.Kind
data PromptTag (a :: Type) = PromptTag (PromptTag# a)
newPromptTag :: IO (PromptTag a)
newPromptTag = IO $ \s0 -> case newPromptTag# s0 of (# s1, tag #) -> (# s1, PromptTag tag #)
prompt :: PromptTag a -> IO a -> IO a
prompt (PromptTag tag) (IO m) = IO $ prompt# tag m
control0 :: PromptTag a -> ((IO b -> IO a) -> IO a) -> IO b
control0 (PromptTag tag) f = IO $ control0# tag (\k -> unIO $ f $ \(IO x) -> IO (k x))
main :: IO ()
main = do
tag <- newPromptTag
prompt tag $ control0 tag (\k -> k (pure ()))
Expected behavior
Binary built without -prof
exits normally. If built with -prof
then the program panics:
Main: GHC.Exts.control0#: no matching prompt in the current continuation
Environment
- GHC version used: 9.6-alpha3
Optional:
- Operating System: Arch Linux
- System Architecture: x64