Skip to content

MemorySanitizer fails on AArch64 Linux when run in QEMU/cross-rs with MemorySanitizer: CHECK failed: sanitizer_allocator_primary64.h:133 "((kSpaceBeg))... #141981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
briansmith opened this issue Jun 3, 2025 · 1 comment
Labels
A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. O-AArch64 Armv8-A or later processors in AArch64 mode PG-exploit-mitigations Project group: Exploit mitigations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@briansmith
Copy link
Contributor

In rust-random/getrandom#681 I discovered that MSAN doesn't work correctly in QEMU user space emulation in its default configuration, and so we cannot use memory sanitizer when using cross-rs. This is a known issue; see llvm/llvm-project#65144. From the LLVM issue comment llvm/llvm-project#65144 (comment):

Can confirm that the issue does not occur with Yocto
Compiling with setting -DSANITIZER_CAN_USE_ALLOCATOR64=0

So, should we build with SANITIZER_CAN_USE_ALLOCATOR64=0 on AArch64 Linux to facilitate this configuration?

(Note that while GitHub Actions does have ARM64 Linux runners now, they don't work in private repos, so people are often still using cross, as it supports PR workflows better.)

RUSTFLAGS=-Dwarnings -Zsanitizer=memory \
RUSTDOCFLAGS=-Dwarnings -Zsanitizer=memory \
cross test --no-fail-fast -Zbuild-std --target=aarch64-unknown-linux-gnu

Output (copied from the comments of the aforementioned getrandom PR:


---- src/lib.rs - (line 162) stdout ----
Test executable failed (exit status: 1).

stderr:
MemorySanitizer: CHECK failed: sanitizer_allocator_primary64.h:133 "((kSpaceBeg)) == ((address_range.Init(TotalSpaceSize, PrimaryAllocatorName, kSpaceBeg)))" (0xe00000000000, 0xfffffffffffffff4) (tid=524)
    <empty stack>



---- src/lib.rs - (line 187) stdout ----
Test executable failed (exit status: 1).

stderr:
MemorySanitizer: CHECK failed: sanitizer_allocator_primary64.h:133 "((kSpaceBeg)) == ((address_range.Init(TotalSpaceSize, PrimaryAllocatorName, kSpaceBeg)))" (0xe00000000000, 0xfffffffffffffff4) (tid=538)
    <empty stack>



---- src/lib.rs - (line 36) stdout ----
Test executable failed (exit status: 1).

stderr:
MemorySanitizer: CHECK failed: sanitizer_allocator_primary64.h:133 "((kSpaceBeg)) == ((address_range.Init(TotalSpaceSize, PrimaryAllocatorName, kSpaceBeg)))" (0xe00000000000, 0xfffffffffffffff4) (tid=552)
    <empty stack>



---- src/lib.rs - fill (line 59) stdout ----
Test executable failed (exit status: 1).

stderr:
MemorySanitizer: CHECK failed: sanitizer_allocator_primary64.h:133 "((kSpaceBeg)) == ((address_range.Init(TotalSpaceSize, PrimaryAllocatorName, kSpaceBeg)))" (0xe00000000000, 0xfffffffffffffff4) (tid=566)
    <empty stack>



---- src/lib.rs - u32 (line 121) stdout ----
Test executable failed (exit status: 1).

stderr:
MemorySanitizer: CHECK failed: sanitizer_allocator_primary64.h:133 "((kSpaceBeg)) == ((address_range.Init(TotalSpaceSize, PrimaryAllocatorName, kSpaceBeg)))" (0xe00000000000, 0xfffffffffffffff4) (tid=580)
    <empty stack>



---- src/lib.rs - u64 (line 135) stdout ----
Test executable failed (exit status: 1).

stderr:
MemorySanitizer: CHECK failed: sanitizer_allocator_primary64.h:133 "((kSpaceBeg)) == ((address_range.Init(TotalSpaceSize, PrimaryAllocatorName, kSpaceBeg)))" (0xe00000000000, 0xfffffffffffffff4) (tid=594)
    <empty stack>
@briansmith briansmith added the C-bug Category: This is a bug. label Jun 3, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 3, 2025
@briansmith
Copy link
Contributor Author

The above was with nightly-2025-06-01.

The same tests pass when run on ubuntu-24.04-arm runners without QEMU/cross:

RUSTFLAGS=-Dwarnings -Zsanitizer=memory \
RUSTDOCFLAGS=-Dwarnings -Zsanitizer=memory \
cargo test -Zbuild-std --target=aarch64-unknown-linux-gnu

@workingjubilee workingjubilee added PG-exploit-mitigations Project group: Exploit mitigations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-sanitizers Area: Sanitizers for correctness and code quality O-AArch64 Armv8-A or later processors in AArch64 mode and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. O-AArch64 Armv8-A or later processors in AArch64 mode PG-exploit-mitigations Project group: Exploit mitigations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants