[Git][ghc/ghc][master] Fix race condition in IOManager test
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 1e568190 by David Eichmann at 2026-11-22T16:40:28-05:00 Fix race condition in IOManager test - - - - - 2 changed files: - testsuite/tests/rts/IOManager.hsc - testsuite/tests/rts/all.T Changes: ===================================== testsuite/tests/rts/IOManager.hsc ===================================== @@ -582,15 +582,15 @@ recvEmptyBufPtcl (EmptyBufPtcl sync) fd = do -- just do simple blocking read\/write of bytes. So this should just be needed -- at the far ends of the hops. -- -data FullBufPtcl = FullBufPtcl !(TVar Bool) !Int -- wait milliseconds +data FullBufPtcl = FullBufPtcl !(TVar Bool) !Int -- wait microseconds newFullBufPtcl :: Int -> IO FullBufPtcl -newFullBufPtcl nhops = FullBufPtcl <$> newTVarIO False <*> pure waitms +newFullBufPtcl nhops = FullBufPtcl <$> newTVarIO False <*> pure waitus where - waitms = nhops * 100 --100ms per hop + waitus = nhops * 100 -- 100µs per hop: 'timeout' takes microseconds sendFullBufPtcl :: FullBufPtcl -> Fd -> Word8 -> IO () -sendFullBufPtcl ptcl@(FullBufPtcl sync _waitms) fd x = do +sendFullBufPtcl ptcl@(FullBufPtcl sync _waitus) fd x = do res <- writeByteNonBlocking fd x case res of Just () -> @@ -606,20 +606,21 @@ sendFullBufPtcl ptcl@(FullBufPtcl sync _waitms) fd x = do sendFullBufPtcl ptcl fd x finishSendFullBufPtcl :: FullBufPtcl -> IO () -finishSendFullBufPtcl (FullBufPtcl sync _waitms) = +finishSendFullBufPtcl (FullBufPtcl sync _waitus) = atomically $ writeTVar sync True -- release reader to finish recvFullBufPtcl :: FullBufPtcl -> Fd -> IO (Maybe Word8) -recvFullBufPtcl (FullBufPtcl sync waitms) fd = do +recvFullBufPtcl ptcl@(FullBufPtcl sync waitus) fd = do atomically $ readTVar sync >>= check res <- readByteNonBlocking fd case res of - Nothing -> fail "recvFullBufPtcl: unexpected blocking" + -- With copy hops in between, the far end can lag behind the sender. + Nothing -> threadWaitRead fd >> recvFullBufPtcl ptcl fd Just Nothing -> return Nothing Just (Just x) -> do traceIO ("recvFullBufPtcl: read byte '" ++ show x ++ "' on fd " ++ show fd ++ ", now waiting") - _ <- timeout waitms $ atomically $ readTVar sync >>= check . not + _ <- timeout waitus $ atomically $ readTVar sync >>= check . not return (Just x) ===================================== testsuite/tests/rts/all.T ===================================== @@ -681,7 +681,7 @@ test('T23400', [], compile_and_run, ['-with-rtsopts -A8k']) test('IOManager', [js_skip, when(arch('wasm32'), skip), when(opsys('mingw32'), skip), pre_cmd('$MAKE -s --no-print-directory IOManager.hs'), when(have_smp(), extra_ways(['threaded2'])), - all_available_io_managers_except(['winio', 'mio'])], + all_available_io_managers_except(['winio'])], compile_and_run, ['']) test('T24142', [req_target_smp], compile_and_run, ['-threaded -with-rtsopts "-N2"']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1e5681902f63fe247d58333d29eaa279... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1e5681902f63fe247d58333d29eaa279... 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)
-
Marge Bot (@marge-bot)