[GHC] #13891: forkIO can trivially defeat bracket

#13891: forkIO can trivially defeat bracket -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider this program, {{{#!hs import Control.Concurrent import Control.Exception main = do putStrLn "forking" forkIO $ bracket (putStrLn "forked") (const $ putStrLn "finalize") (const $ putStrLn "hello" >> threadDelay 100000000) threadDelay 10000 putStrLn "done" }}} Would you predict that it would print `finalize`? Answer: no. It will print, {{{ forking forked hello done }}} It would pointed out by an author of a cryptographic library (`raaz`) that this is quite bad as it means that secure memory could leak out uncleared. It's not entirely clear how best to deal with this. Perhaps raise a `ThreadKilled` async exception to all running threads during RTS shutdown, followed by a synchronization? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13891 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13891: forkIO can trivially defeat bracket -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * cc: Jaffacake (added) Comment: Simon, what is the recommended way of dealing with this? It seems to me like this should be considered a bug and we should throw exceptions to threads before terminating. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13891#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13891: forkIO can trivially defeat bracket -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: wontfix | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonmar): * status: new => closed * resolution: => wontfix Comment: The right solution to this is to use `withAsync` from the `async` package instead of `forkIO`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13891#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC