Skip to content

Re-enable AddressSanitizer on aarch64 via native arm64 runners#461

Open
aflores-qb wants to merge 1 commit into
toniebox-reverse-engineering:developfrom
aflores-qb:fix/311-enable-asan-aarch64-native-runner
Open

Re-enable AddressSanitizer on aarch64 via native arm64 runners#461
aflores-qb wants to merge 1 commit into
toniebox-reverse-engineering:developfrom
aflores-qb:fix/311-enable-asan-aarch64-native-runner

Conversation

@aflores-qb

Copy link
Copy Markdown

Closes #311.

Root cause

The aarch64 images are cross-built and then run (docker run test step) under QEMU-user emulation. AddressSanitizer aborts at startup there:

CHECK failed: sanitizer_allocator_primary64.h:131 "((kSpaceBeg)) == ((address_range.Init(...)))" (0x500000000000, 0xfffffffffffffff4)

QEMU's constrained emulated address space can't host libasan's fixed 64-bit allocator region, so the mmap returns -ENOMEM (0xfffffffffffffff4 == -12). That failing test is why ASan was disabled on arm64 via NO_SANITIZERS=2 (noasan_fallback_platforms).

Side note: the -DSANITIZER_CAN_USE_ALLOCATOR64=0 workaround in the Makefile was a no-op — that define only takes effect when libasan itself is compiled, not the application (hence the "But this doesn't work!" comment). Those dead blocks are removed.

Fix

Build and test aarch64 on native ubuntu-24.04-arm runners (free for public repos, GA Aug 2025) instead of under QEMU. On real hardware ASan initialises normally, so linux/arm64/v8 is dropped from noasan_fallback_platforms and ships with ASan again (ubuntu + debian). No ASLR/security tradeoff and no change to what's shipped beyond re-enabling ASan.

Changes

  • publish_docker_matrix_base.yml — route linux/arm64/v8 to ubuntu-24.04-arm (everything else stays on the amd64 runner + QEMU); add a CI-only sysctl vm.mmap_rnd_bits=28 before the arm64 test as cheap insurance in case a base image ever ships a pre-LLVM-17 libasan (GCC ≤13).
  • publish_docker_matrix_all.yml — remove linux/arm64/v8 from noasan_fallback_platforms for ubuntu + debian; narrow the *AsanTest canaries to the platforms still under QEMU (armv7, ppc64le).
  • Makefile — delete the dead SANITIZER_CAN_USE_ALLOCATOR64=0 blocks and document the actual cause/fix.

armv7 and ppc64le stay on the QEMU fallback (NO_SANITIZERS=2); the AsanTest canary jobs keep probing them.

Notes / validation

  • Reproduced locally on native arm64 (Docker, Apple Silicon): a clean ASan binary on the current ubuntu:latest/debian:latest toolchains starts fine even at vm.mmap_rnd_bits=32; under QEMU it aborts with the issue's CHECK — consistent with the diagnosis.
  • This PR's own CI runs the arm64 build + docker run test on the native runner (the PR build path loads the image locally and skips push/merge), so the green/red result here directly validates that ASan works on arm64.
  • Rollback if ever needed is one line: re-add "linux/arm64/v8" to noasan_fallback_platforms.

The aarch64 Docker images were built and tested under QEMU-user
emulation, where the ASan-instrumented binary aborts at startup
(CHECK failed: sanitizer_allocator_primary64.h) because QEMU's
emulated address space cannot host libasan's fixed 64-bit allocator
region. ASan was therefore disabled on arm64 via NO_SANITIZERS=2.

Run the arm64 build/test on native ubuntu-24.04-arm runners instead
of under QEMU, where ASan initialises normally, and drop arm64 from
noasan_fallback_platforms so it builds with ASan again (ubuntu+debian).

- publish_docker_matrix_base.yml: route linux/arm64/v8 to a native
  ubuntu-24.04-arm runner; skip the multiarch/qemu-user-static binfmt
  registration on that native runner (it is amd64-only and fails with
  "Exec format error" there, and is unneeded since arm64 containers run
  natively); lower vm.mmap_rnd_bits to 28 before the arm64 test as cheap
  CI-only insurance for older base-image libasan.
- publish_docker_matrix_all.yml: remove linux/arm64/v8 from
  noasan_fallback_platforms (ubuntu, debian); narrow the AsanTest
  canaries to the platforms still under QEMU (armv7, ppc64le).
- Makefile: drop the dead -DSANITIZER_CAN_USE_ALLOCATOR64=0 blocks
  (the define only affects libasan's own build, not the application)
  and document the real cause and fix.
@aflores-qb aflores-qb force-pushed the fix/311-enable-asan-aarch64-native-runner branch from 05176d3 to b218195 Compare June 21, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant