Skip to content

UnsafeReenter test fails with threaded1 and threaded2

  /tmp/ghctest-n4fi8zlk/test   spaces/./ffi/should_fail/UnsafeReenter.run          UnsafeReenter [bad exit code] (threaded1)
  /tmp/ghctest-n4fi8zlk/test   spaces/./ffi/should_fail/UnsafeReenter.run          UnsafeReenter [bad exit code] (threaded2)

It's a quite simple program:

{-# LANGUAGE ForeignFunctionInterface #-}
  
-- | Test that unsafe FFI calls crash the RTS if they attempt to re-enter
-- Haskell-land
module Main where
  
import Foreign
  
foreign import ccall "wrapper" wrap_f :: IO () -> IO (FunPtr (IO ()))
foreign import ccall unsafe hello :: FunPtr (IO ()) -> IO ()
  
f :: IO ()
f = putStrLn "Back in Haskell"
  
main :: IO ()
main = do
    putStrLn "In Haskell"
    wrap_f f >>= hello
    putStrLn "Finished"

This just seem to hang (until timeout) with the threaded1 and threaded2 ways, instead of erroring out with:

  UnsafeReenter: schedule: re-entered unsafely.
     Perhaps a 'foreign import unsafe' should be 'safe'?

which is the expected behaviour. I'll mark the test broken for those 2 ways in an upcoming patch, but this probably deserves a new ticket, so here it is.

Trac metadata
Trac field Value
Version 8.5
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Runtime System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information