ICE with SIGSEGV when compiling simple program with -C target-cpu=native when using Mimalloc allocator
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Note: The problem no longer occurs after removing target-cpu=native.
Code
fn main() { println!("Hello, world!"); }
// Yes I 100% sure this is no a joke!
Meta
rustc --version --verbose:
rustc 1.92.0 (ded5c06cf 2025-12-08)
binary: rustc
commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234
commit-date: 2025-12-08
host: x86_64-unknown-linux-gnu
release: 1.92.0
LLVM version: 21.1.3
Reproduce
┌──(kris㉿KrisTHL181)-[/tmp]
└─$ LD_PRELOAD=/lib/x86_64-linux-gnu/libc.so.6 rustc a.rs -C target-cpu=native
┌──(kris㉿KrisTHL181)-[/tmp]
└─$ LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so rustc a.rs -C target-cpu=native
┌──(kris㉿KrisTHL181)-[/tmp]
└─$ LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libmimalloc.so MIMALLOC_SHOW_ERRORS=1 rustc a.rs -C target-cpu=native
mimalloc: warning: unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x10000 bytes, address: 0x7F26A6B8C000, alignment: 0x10000, commit: 1)
error: rustc interrupted by SIGSEGV, printing backtrace
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x3c04adf) [0x7f904e404adf]
/usr/lib/x86_64-linux-gnu/libc.so.6(+0x40590) [0x7f904a440590]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc(+0x12d62) [0x55f4897b8d62]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(_RNvNtCsbG23ezydE5t_18rustc_codegen_llvm9llvm_util20global_llvm_features+0x3fe) [0x7f9050bb937e]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x63b6d7a) [0x7f9050bb6d7a]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(_RNvXs3_CsbG23ezydE5t_18rustc_codegen_llvmNtB5_18LlvmCodegenBackendNtNtNtCskkDJNHb7lVI_17rustc_codegen_ssa6traits7backend14CodegenBackend13target_config+0x26) [0x7f9050bb55e6]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(_RNvNtCs5jXuXMnic4K_15rustc_interface4util17add_configuration+0x25) [0x7f9050d41225]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x6593b0d) [0x7f9050d93b0d]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x614a300) [0x7f905094a300]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x6149fe4) [0x7f9050949fe4]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x614896f) [0x7f905094896f]
/usr/lib/x86_64-linux-gnu/libc.so.6(+0x937db) [0x7f904a4937db]
/usr/lib/x86_64-linux-gnu/libc.so.6(+0x111278) [0x7f904a511278]
note: we would appreciate a report at https://github.com/rust-lang/rust
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
zsh: segmentation fault (core dumped) LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libmimalloc.so MIMALLOC_SHOW_ERRORS=1
Error output
(It still happens when the stack size is increased)
error: rustc interrupted by SIGSEGV, printing backtrace
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x3c04adf) [0x7f812d204adf]
/lib/x86_64-linux-gnu/libc.so.6(+0x3fdf0) [0x7f8129449df0]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc(+0x12d62) [0x56280e178d62]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(_RNvNtCsbG23ezydE5t_18rustc_codegen_llvm9llvm_util20global_llvm_features+0x3fe) [0x7f812f9b937e]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x63b6d7a) [0x7f812f9b6d7a]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(_RNvXs3_CsbG23ezydE5t_18rustc_codegen_llvmNtB5_18LlvmCodegenBackendNtNtNtCskkDJNHb7lVI_17rustc_codegen_ssa6traits7backend14CodegenBackend13target_config+0x26) [0x7f812f9b55e6]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(_RNvNtCs5jXuXMnic4K_15rustc_interface4util17add_configuration+0x25) [0x7f812fb41225]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x6593b0d) [0x7f812fb93b0d]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x614a300) [0x7f812f74a300]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x6149fe4) [0x7f812f749fe4]
/home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so(+0x614896f) [0x7f812f74896f]
/lib/x86_64-linux-gnu/libc.so.6(+0x92b7b) [0x7f812949cb7b]
/lib/x86_64-linux-gnu/libc.so.6(+0x1107b8) [0x7f812951a7b8]
note: we would appreciate a report at https://github.com/rust-lang/rust
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
zsh: segmentation fault (core dumped) rustc -C opt-level=3 -C target-cpu=native -O a.rs -o digit_freq
--
Kernel log:
[52400.478510] rustc[421648]: segfault at 1d3180 ip 000055d8e0e5ed62 sp 00007f72fbbcf040 error 4 in rustc[11d62,55d8e0e5e000+7b000] likely on CPU 2 (core 1, socket 0)
[52400.478533] Code: 00 48 8b ac 0b b0 01 00 00 4c 39 f5 0f 85 92 06 00 00 4d 8b 67 08 89 f8 c1 e8 09 25 f8 ff 1f 00 4c 01 e0 4c 8d b3 58 03 00 00 <48> 8b 08 48 89 c8 48 c1 e8 30 48 8d 2d cd a6 28 00 4c 8b 6c c5 00
Backtrace
(note: it didn't change anything; the output was the same as before)
<backtrace>
GDB
┌──(kris㉿KrisTHL181)-[/tmp]
└─$ LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libmimalloc.so gdb --args rustc a.rs -C target-cpu=native
GNU gdb (Debian 17.1-1) 17.1
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from rustc...
(No debugging symbols found in rustc)
⚠️ warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /usr/bin/rustup.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) r
Starting program: /usr/bin/rustc a.rs -C target-cpu=native
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/x86_64-linux-gnu/libthread_db.so.1".
process 6005 is executing new program: /home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe57bf6c0 (LWP 6011)]
[New Thread 0x7fffe4fff6c0 (LWP 6012)]
[New Thread 0x7fffe41ff6c0 (LWP 6013)]
Thread 3 "rustc" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe4fff6c0 (LWP 6012)]
0x0000555555566d62 in free_default ()
(gdb) bt full
#0 0x0000555555566d62 in free_default ()
No symbol table info available.
#1 0x00007ffff65b937e in rustc_codegen_llvm::llvm_util::global_llvm_features ()
from /home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so
No symbol table info available.
#2 0x00007ffff65b6d7a in rustc_codegen_llvm::back::write::create_informational_target_machine ()
from /home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so
No symbol table info available.
#3 0x00007ffff65b55e6 in <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::target_config ()
from /home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so
No symbol table info available.
#4 0x00007ffff6741225 in rustc_interface::util::add_configuration ()
from /home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so
No symbol table info available.
#5 0x00007ffff6793b0d in rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1} ()
from /home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so
No symbol table info available.
#6 0x00007ffff634a300 in std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()> () from /home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so
No symbol table info available.
#7 0x00007ffff6349fe4 in <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} ()
from /home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so
No symbol table info available.
#8 0x00007ffff634896f in std::sys::thread::unix::Thread::new::thread_start ()
from /home/kris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d31eb41759495bb2.so
No symbol table info available.
#9 0x00007fffefe937db in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:448
ret = <optimized out>
pd = <optimized out>
out = <optimized out>
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {128, -2340640383823732939, 32, 2, 140737488302560, 140737488302808, -2340629391408537398, -2340605352509742902},
mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
not_first_call = <optimized out>
#10 0x00007fffeff11278 in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
No locals.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the crash with the minimal Rust program, -C target-cpu=native, and the shown LD_PRELOAD mimalloc command. Start by inspecting rustc_codegen_llvm::llvm_util::global_llvm_features, create_informational_target_machine, and target_config from the GDB backtrace. Done means rustc no longer segfaults in this configuration, with a regression test if the relevant test location is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100