Miri Panic On AArch64 Linux: 16K Page Size Fix
Introduction
Hey guys! Today, we're diving into a tricky issue that some of you might encounter when running Miri, Rust's amazing interpreter for testing program behavior, on AArch64 Linux systems, especially those with a 16K page size. This is a common setup for ARM Macs running Linux, like the M2 MacBook Air. We'll break down the problem, show you the error messages, and, most importantly, give you a workaround to get Miri up and running. Let's get started!
The Problem: Miri and 16K Page Size on AArch64 Linux
The main issue arises when trying to run Miri on an AArch64 Linux system that uses a 16K page size. This configuration is standard for ARM Macs when running Linux, such as on the M2 MacBook Air. While you might think this is a smooth setup, Miri can throw a wrench in the gears. There are, of course, performance drawbacks to using 4k kernels, and the 16k page size is generally preferred for optimal performance. Moreover, sticking with a 4k kernel can sometimes lead to stability issues, making the 16k option even more appealing.
So, what happens when you try to run Miri in this environment? You'll likely encounter a panic, and not the good kind. Let's look at the error message to understand better what's going on under the hood.
Decoding the Error Message
When Miri panics due to the 16K page size issue, you'll see an error message that looks something like this:
thread 'main' panicked at src/tools/miri/cargo-miri/src/phases.rs:98:9:
failed to determine underlying rustc version of Miri (MIRI_BE_RUSTC="host" "/home/i509vcb/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/bin/miri"):
CommandError { stdout: "", stderr: "<jemalloc>: Unsupported system page size\n<jemalloc>: Unsupported system page size\nLLVM ERROR: out of memory\nAllocation failed\n" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Let's break this down:
thread 'main' panicked at src/tools/miri/cargo-miri/src/phases.rs:98:9:
This tells us that the main thread crashed within Miri's source code, specifically in thephases.rs
file.failed to determine underlying rustc version of Miri
This indicates that Miri couldn't figure out the Rust compiler version it's working with, which is a critical step for its operation.CommandError { stdout: "", stderr: "<jemalloc>: Unsupported system page size\n<jemalloc>: Unsupported system page size\nLLVM ERROR: out of memory\nAllocation failed\n" }
This is the meat of the issue. The error messages fromjemalloc
, a memory allocator, clearly state that the system page size is unsupported. This is the key clue that points to the 16K page size being the culprit. Additionally, the