rust-lang / rust-lang/rust

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

Open
#141,981 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-LLVM A-sanitizers C-bug O-AArch64 PG-exploit-mitigations T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

In https://github.com/rust-random/getrandom/pull/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 https://github.com/llvm/llvm-project/issues/65144. From the LLVM issue comment https://github.com/llvm/llvm-project/issues/65144#issuecomment-2605646726:

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>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked LLVM issue and reproduce the failure using the provided RUSTFLAGS, RUSTDOCFLAGS, and cross test command for aarch64-unknown-linux-gnu. Investigate the AArch64 Linux sanitizer build configuration; done means MemorySanitizer no longer hits the allocator CHECK when run through QEMU or cross-rs.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, rust
Domain
build-system, compilers, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.