[Git][ghc/ghc][master] rts: fix rts_clearMemory logic when sanity checks are enabled

Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 86406f48 by Cheng Shao at 2025-05-20T09:19:47-04:00 rts: fix rts_clearMemory logic when sanity checks are enabled This commit fixes an RTS assertion failure when invoking rts_clearMemory with +RTS -DS. -DS implies -DZ which asserts that free blocks contain 0xaa as the designated garbage value. Also adds the sanity way to rts_clearMemory test to prevent future regression. Closes #26011. ChatGPT Codex automatically diagnosed the issue and proposed the initial patch in a single shot, given a GHC checkout and the following prompt: --- Someone is reporting the following error when attempting to use `rts_clearMemory` with the RTS option `-DS`: ``` test.wasm: internal error: ASSERTION FAILED: file rts/sm/Storage.c, line 1216 (GHC version 9.12.2.20250327 for wasm32_unknown_wasi) Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` What's the culprit? How do I look into this issue? --- I manually reviewed & revised the patch, tested and submitted it. - - - - - 2 changed files: - rts/sm/Storage.h - testsuite/tests/ffi/should_run/all.T Changes: ===================================== rts/sm/Storage.h ===================================== @@ -213,7 +213,8 @@ extern StgIndStatic * debug_caf_list; extern StgIndStatic * revertible_caf_list; INLINE_HEADER void clear_blocks(bdescr *bd) { - memset(bd->start, 0, BLOCK_SIZE * bd->blocks); + memset(bd->start, RtsFlags.DebugFlags.zero_on_gc ? 0xaa : 0, + BLOCK_SIZE * bd->blocks); } #include "EndPrivate.h" ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -188,8 +188,8 @@ test('ffi023', [ omit_ghci, test('rts_clearMemory', [ # We only care about different GC configurations under the # single-threaded RTS for the time being. - only_ways(['normal', 'optasm' ,'g1', 'nursery_chunks', 'nonmoving', 'compacting_gc']), - extra_ways(['g1', 'nursery_chunks', 'nonmoving', 'compacting_gc']), + only_ways(['normal', 'optasm' ,'g1', 'nursery_chunks', 'nonmoving', 'compacting_gc', 'sanity']), + extra_ways(['g1', 'nursery_chunks', 'nonmoving', 'compacting_gc', 'sanity']), # On windows, nonmoving way fails with bad exit code (2816) when(opsys('mingw32'), fragile(23091)), req_c, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/86406f48659a5ab61ce1fd2a2d427fab... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/86406f48659a5ab61ce1fd2a2d427fab... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)