[GHC] #8035: STM transaction left open if there is an orElse on the path between throwSTM and catchSTM

#8035: STM transaction left open if there is an orElse on the path between throwSTM and catchSTM -----------------------------+---------------------------------------------- Reporter: errge | Owner: Type: bug | Status: new Priority: normal | Component: Runtime System Version: 7.7 | Keywords: stm rts Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Runtime crash | Blockedby: Blocking: | Related: -----------------------------+---------------------------------------------- {{{ main = join $ atomically $ do catchSTM (throwSTM ThreadKilled `orElse` return (putStrLn "wtf")) (\(e::SomeException) -> return (putStrLn "ok")) }}} This program crashes with a segmentation fault. Tested with GHC HEAD. I attach the testcase and my proposed fix for the issue. I've run the fast testsuite with the proposed fix without new defects. On the other hand I'm very new to GHC, so while I'm sure in the defect and the test, the fix may be bogus. Thanks goes to Mihály Bárász for discovering the issue. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/8035 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8035: STM transaction left open if there is an orElse on the path between throwSTM and catchSTM ---------------------------------+------------------------------------------ Reporter: errge | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.7 Keywords: stm rts | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by simonpj): * difficulty: => Unknown Comment: Wow! A patch with the bug report! Thanks. Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/8035#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8035: STM transaction left open if there is an orElse on the path between throwSTM and catchSTM ---------------------------------+------------------------------------------ Reporter: errge | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.7 Keywords: stm rts | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by simonmar): The patch looks plausible to me, because it's basically copying the code from `raiseAsync` for asynchronous exceptions and using it in the synchronous exception case. I don't like the implicit fallthrough - please at least add a `/* fallthrough */` comment. Let's also see whether Tim can think of anything that might go wrong. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/8035#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8035: STM transaction left open if there is an orElse on the path between throwSTM and catchSTM ---------------------------------+------------------------------------------ Reporter: errge | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.7 Keywords: stm rts | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by errge): Well, actually I was actually recognizing the missing transaction close by a lot of fprintf(stderr). Then copied the code for aborting a transaction from findRetryFrameHelper, which is just below in the same file. But your reasoning sounds easier :) Anyway, I uploaded a new patch, that contains no fallthrough. On the other hand, this means that now we'll have three places for very similar code. Should we try to write a helper function somewhere? Or if there are too many variables to pass, then a helper macro maybe? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/8035#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8035: STM transaction left open if there is an orElse on the path between throwSTM and catchSTM ---------------------------------+------------------------------------------ Reporter: errge | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.7 Keywords: stm rts | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Runtime crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by fryguybob): * cc: fryguybob@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/8035#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8035: STM transaction left open if there is an orElse on the path between
throwSTM and catchSTM
---------------------------------+------------------------------------------
Reporter: errge | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Runtime System | Version: 7.7
Keywords: stm rts | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: Runtime crash
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by ian@…):
commit 60cb478f16c0703e0e97a528869905333d9b3135
{{{
Author: Ian Lynagh
participants (1)
-
GHC