Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 67c03eb2 by Cheng Shao at 2026-07-08T16:54:09-04:00 ghc-heap: fix invalid srtlen returned by peekItbl when no-TNTC This patch fixes the no-TNTC code path of `peekItbl` so that it looks at the right memory address when reading the `srt` field from the `StgInfoTable_` struct. Also adds a `T27465` regression test that reproduces the bug on no-TNTC builds before the fix. Fixes #27465. Co-authored-by: Codex <codex@openai.com> - - - - - 6 changed files: - + changelog.d/fix-peekitbl-no-tntc - + libraries/ghc-heap/tests/T27465.hs - + libraries/ghc-heap/tests/T27465.stdout - libraries/ghc-heap/tests/all.T - libraries/ghc-internal/src/GHC/Internal/Heap/InfoTable.hsc - libraries/ghc-internal/src/GHC/Internal/Heap/InfoTableProf.hsc Changes: ===================================== changelog.d/fix-peekitbl-no-tntc ===================================== @@ -0,0 +1,4 @@ +section: ghc-heap +synopsis: Fix invalid srtlen field returned by peekItbl when no tables-next-to-code +issues: #27465 +mrs: !16289 ===================================== libraries/ghc-heap/tests/T27465.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE MagicHash #-} + +import GHC.Exts +import GHC.Exts.Heap + +data T = A | B | C + +main :: IO () +main = do + clos <- getClosureData C + let expected = I# (dataToTag# C) + case clos of + ConstrClosure {info = itbl, name = con} -> do + putStrLn $ "constructor: " ++ con + putStrLn $ "expected tag: " ++ show expected + putStrLn $ "srtlen field: " ++ show (srtlen itbl) + if fromIntegral (srtlen itbl) == expected + then putStrLn "OK" + else fail "peekItbl returned wrong srtlen" + _ -> fail $ "unexpected closure: " ++ show clos ===================================== libraries/ghc-heap/tests/T27465.stdout ===================================== @@ -0,0 +1,4 @@ +constructor: C +expected tag: 2 +srtlen field: 2 +OK ===================================== libraries/ghc-heap/tests/all.T ===================================== @@ -105,3 +105,8 @@ test('stack_misc_closures', ] , '-debug' # Debug RTS to use checkSTACK() (Sanity.c) ]) + +test('T27465', + [ when(have_profiling(), extra_ways(['prof'])) + ], + compile_and_run, ['']) ===================================== libraries/ghc-internal/src/GHC/Internal/Heap/InfoTable.hsc ===================================== @@ -49,7 +49,7 @@ peekItbl a0 = do ptrs' <- (#peek struct StgInfoTable_, layout.payload.ptrs) ptr nptrs' <- (#peek struct StgInfoTable_, layout.payload.nptrs) ptr tipe' <- (#peek struct StgInfoTable_, type) ptr - srtlen' <- (#peek struct StgInfoTable_, srt) a0 + srtlen' <- (#peek struct StgInfoTable_, srt) ptr return StgInfoTable { entry = entry' , ptrs = ptrs' ===================================== libraries/ghc-internal/src/GHC/Internal/Heap/InfoTableProf.hsc ===================================== @@ -46,7 +46,7 @@ peekItbl a0 = do ptrs' <- (#peek struct StgInfoTable_, layout.payload.ptrs) ptr nptrs' <- (#peek struct StgInfoTable_, layout.payload.nptrs) ptr tipe' <- (#peek struct StgInfoTable_, type) ptr - srtlen' <- (#peek struct StgInfoTable_, srt) a0 + srtlen' <- (#peek struct StgInfoTable_, srt) ptr return StgInfoTable { entry = entry' , ptrs = ptrs' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/67c03eb2c762fdfeb646eb8345341173... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/67c03eb2c762fdfeb646eb8345341173... You're receiving this email because of your account on gitlab.haskell.org.