arch/sim: Add MM_FILL_ALLOCATIONS support to sim customized heap.#18966
Merged
Conversation
When CONFIG_MM_UMM_CUSTOMIZE_MANAGER is enabled, the sim heap bypasses mm_heap/tlsf entirely and calls host malloc/free directly, so MM_FILL_ALLOCATIONS has no effect. Add fill pattern support directly in sim_ummheap.c: - malloc: fill user region with 0xaa - free: fill user region with 0x55 - realloc: fill extended region with 0xaa This helps detect uninitialized reads in sim environment, which ASan does not support. Signed-off-by: yushuailong <yyyusl@qq.com>
xiaoxiang781216
approved these changes
May 26, 2026
acassis
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When CONFIG_MM_UMM_CUSTOMIZE_MANAGER is enabled, the sim heap bypasses mm_heap/tlsf entirely and calls host malloc/free directly, so MM_FILL_ALLOCATIONS has no effect. Add fill pattern support directly in sim_ummheap.c:
This helps detect uninitialized reads in sim environment, which ASan does not support.
Impact
Only affects sim arch when both CONFIG_MM_UMM_CUSTOMIZE_MANAGER and CONFIG_MM_FILL_ALLOCATIONS are enabled.
Testing
Host: Linux x86_64 (Ubuntu)
Board: sim (simulator)
Config: sim:ostest with CONFIG_MM_UMM_CUSTOMIZE_MANAGER=y and CONFIG_MM_FILL_ALLOCATIONS=y
Toolchain: GCC
Test case :
Test log:
=== MM_FILL_ALLOCATIONS Test ===
TEST: malloc fill 0xaa ... PASS
TEST: free fill 0x55 ... PASS
TEST: realloc extend fill 0xaa ... PASS
TEST: realloc shrink preserves data ... PASS
=== Test Complete ===
All 4 tests pass.