[Git][ghc/ghc][wip/fix-9809] Add a test for the fix for #9809
Erik de Castro Lopo pushed to branch wip/fix-9809 at Glasgow Haskell Compiler / GHC Commits: 59d99193 by Erik de Castro Lopo at 2026-10-26T12:33:50+11:00 Add a test for the fix for #9809 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - 3 changed files: - libraries/base/tests/.gitignore - + libraries/base/tests/T9809.hs - libraries/base/tests/all.T Changes: ===================================== libraries/base/tests/.gitignore ===================================== @@ -275,4 +275,5 @@ /weak001 /T9395 /T9532 +/T9809 /T11555 ===================================== libraries/base/tests/T9809.hs ===================================== @@ -0,0 +1,29 @@ +-- #9809: when many threads registered timeouts at the same time, the +-- TimerManager published unevaluated timeout queues with atomicModifyIORef'. +-- The threads then built long chains of thunks and blocked on each other's +-- black holes, and the heap grew to hundreds of megabytes. all.T runs this +-- test with a heap limit that the old code exceeded. + +import Control.Concurrent +import Control.Monad +import Data.IORef +import GHC.Conc (TVar, atomically, newTVarIO, readTVar, registerDelay, retry, writeTVar) + +main :: IO () +main = do + let n = 100000 + ref <- newIORef [] + registered <- newTVarIO (0 :: Int) + replicateM_ n . forkIO $ do + tv <- registerDelay 10 + atomicModifyIORef' ref (\tvs -> (tv : tvs, ())) + atomically $ readTVar registered >>= writeTVar registered . (+ 1) + atomically $ do + r <- readTVar registered + when (r /= n) retry + readIORef ref >>= mapM_ waitFor + +-- | Block until a delay has fired, so that the test also checks that the +-- TimerManager fires every timeout. +waitFor :: TVar Bool -> IO () +waitFor tv = atomically $ readTVar tv >>= \fired -> unless fired retry ===================================== libraries/base/tests/all.T ===================================== @@ -193,6 +193,12 @@ test('T7653', [when(opsys('mingw32'), skip), omit_ways(prof_ways + ghci_ways)], compile_and_run, ['']) test('T7787', normal, compile_and_run, ['']) +# Before the fix for #9809 this needed more than 256MB of heap. +test('T9809', [req_ghc_smp, + req_target_smp, + only_ways(['threaded1', 'threaded2', 'nonmoving_thr'])], + compile_and_run, ['-threaded -with-rtsopts="-N2 -M128m"']) + test('topHandler01', [when(opsys('mingw32'), skip), js_broken(22261), req_process], compile_and_run, ['']) test('topHandler02', [when(opsys('mingw32'), skip), View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59d99193c7d12922dc7ce2351c7cf28a... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59d99193c7d12922dc7ce2351c7cf28a... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Erik de Castro Lopo (@erikd)