rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.14k stars 12.8k forks source link

`miri` is incorrectly built with jemalloc on some targets #133748

Open pitust opened 23 hours ago

pitust commented 23 hours ago

I tried to run cargo miri run in (any) workspace on Asahi Linux (which has 16k page kernels)

I expected to see this happen: The program runs under miri similarly to how rustc works

Instead, this happened:

thread 'main' panicked at src/tools/miri/cargo-miri/src/phases.rs:103:9:
failed to determine underlying rustc version of Miri (MIRI_BE_RUSTC="host" "/home/pitust/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/bin/miri"):
CommandError { stdout: "", stderr: "<jemalloc>: Unsupported system page size\n<jemalloc>: Unsupported system page size\nterminate called without an active exception\n" }
stack backtrace:
   0: rust_begin_unwind
             at /rustc/5e1440ae514d98ddfcbf1607acb64d41e07ef616/library/std/src/panicking.rs:681:5
   1: core::panicking::panic_fmt
             at /rustc/5e1440ae514d98ddfcbf1607acb64d41e07ef616/library/core/src/panicking.rs:75:14
   2: cargo_miri::phases::phase_cargo_miri::<std::env::Args>
   3: cargo_miri::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Meta

rustc --version --verbose:

rustc 1.85.0-nightly (5e1440ae5 2024-12-01)
binary: rustc
commit-hash: 5e1440ae514d98ddfcbf1607acb64d41e07ef616
commit-date: 2024-12-01
host: aarch64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4
Noratrieb commented 23 hours ago

Foe context: jemalloc does not work on Linux with 16k pages, it hardcodes 4k: https://github.com/jemalloc/jemalloc/issues/467 rustc works, so I suspect it's not being built with jemalloc on that target. Miris jenalloc logic is unconditional and not coupled to bootstrap jenalloc logic, which seems like the problem.

Mark-Simulacrum commented 22 hours ago

That issue makes it sound like jemalloc should be able to work on this system (i.e., the hardcoding was removed?) if we (or maybe jemalloc-sys?) compiled it with e.g. a 64k "page" target? At least, that's my impression of the closing comment.

Noratrieb commented 21 hours ago

Yes, we could compile jemalloc to make it work properly (and actually maybe that's what's already happening for rustc? unsure)