Opened 5 years ago

Closed 5 years ago

#9379 closed bug (fixed)

Blocked STM transaction is not interruptible

Reported by: Feuerbach Owned by: simonmar
Priority: normal Milestone: 7.8.4
Component: Runtime System Version: 7.8.3
Keywords: Cc: simonmar
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


import Control.Exception
import Control.Concurrent
import Control.Concurrent.STM
import Foreign.StablePtr

main :: IO ()
main = do
  tv <- atomically $ newTVar True
  _ <- newStablePtr tv
  t <- mask_ $ forkIO (blockSTM tv)
  killThread t

blockSTM :: TVar Bool -> IO ()
blockSTM tv = do
  atomically $ do
    v <- readTVar tv
    check $ not v

This code blocks forever. As I understand it, since the transaction blocks, it should be interruptible even despite the mask, and so killThread must succeed here, and the program should finish promptly.

Change History (4)

comment:1 Changed 5 years ago by simonmar

Differential Rev(s):

comment:2 Changed 5 years ago by Simon Marlow <marlowsd@…>

In 9d9a55469719908bbd5cd3277e0ac79c0588dc55/ghc:

interruptible() was not returning true for BlockedOnSTM (#9379)

There's an knock-on fix in HeapStackCheck.c which is potentially
scary, but I'm pretty confident is OK.  See comment for details.

Test Plan:
I've run all the STM
tests I can find, including libraries/stm/tests/stm049 with +RTS -N8
and some of the constants bumped to make it more of a stress test.

Reviewers: hvr, rwbarton, austin

Subscribers: simonmar, relrod, ezyang, carter

Differential Revision:

GHC Trac Issues: #9379

comment:3 Changed 5 years ago by simonmar

Milestone: 7.8.4
Status: newmerge

comment:4 Changed 5 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed


Note: See TracTickets for help on using tickets.