sandbox: Add -M option to disable mcheck at runtime

Add a command-line option (-M or --no_mcheck) to disable mcheck heap
protection at runtime. When mcheck is disabled, the wrapper functions
pass through directly to the underlying allocator without adding
headers or checking for corruption.

This is useful for debugging when mcheck interferes with test results,
such as when memory-leak detection reports false positives due to
accumulated allocations from other tests.

Changes:
- Add disable_mcheck flag to sandbox_state
- Add mcheck_set_disabled() function to mcheck API
- Modify dlmalloc wrappers to bypass mcheck when disabled
- Add stub for when MCHECK_HEAP_PROTECTION is not enabled
- Document the new option in sandbox.rst

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2026-01-01 11:27:49 -07:00
parent e77755ed85
commit b4f6fdbcd2
5 changed files with 64 additions and 1 deletions

View File

@@ -181,6 +181,13 @@ available options. Some of these are described below:
all log statements at LOGL_DEBUG and below. The higher the number, the more
info is shown.
-M, --no_mcheck
Disable mcheck heap protection at runtime. When enabled, the mcheck wrapper
functions pass through directly to the underlying allocator without adding
headers or checking for corruption. This is useful for debugging when mcheck
interferes with test results, such as when memory-leak detection reports false
positives due to accumulated allocations from other tests.
-m, --memory <filename>
Sets the location of the file which holds sandbox's emulated RAM. This can be
read and written across phases, so that sandbox behaves like a normal board.