Skip to content

rustc on NixOS produces SIGBUS: access to undefined memory #142865

Open
@Noah765

Description

@Noah765

I published a reproducible example at https://github.com/Noah765/rust-bug. Adding the dependency tokio with the macros feature enabled results in the error. Interestingly, although the output states that the compilation of quote failed, compilation succeeds when tokio is replaced with quote.

Meta

I am using NixOS and installed Rust using rustup. I added a flake to the example repository that provides a devshell with the rustup version I used. The issue persists when using nightly, as well as when installing cargo from nixpkgs instead of using rustup.

rustc --version --verbose:

rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.87.0
LLVM version: 20.1.1
Backtrace

   Compiling proc-macro2 v1.0.95
   Compiling unicode-ident v1.0.18
   Compiling pin-project-lite v0.2.16
   Compiling quote v1.0.40
   Compiling syn v2.0.104
error: rustc interrupted by SIGBUS, printing backtrace

/home/noah/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-9c23edfdcf82221e.so(+0x39177df) [0x7ffff3f177df]
/nix/store/q4wq65gl3r8fy746v9bbwgx4gzn0r2kl-glibc-2.40-66/lib/libc.so.6(+0x419c0) [0x7ffff02419c0]
/nix/store/q4wq65gl3r8fy746v9bbwgx4gzn0r2kl-glibc-2.40-66/lib/libc.so.6(+0x17f081) [0x7ffff037f081]
/home/noah/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-9c23edfdcf82221e.so(_RNvMs2_NtCs2kjfqayDDYo_6object5writeNtB5_7Section11append_data+0x108) [0x7ffff6750d5e]
/home/noah/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-9c23edfdcf82221e.so(+0x6150ea4) [0x7ffff6750ea4]
/home/noah/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-9c23edfdcf82221e.so(+0x5fcbe3f) [0x7ffff65cbe3f]
/home/noah/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-9c23edfdcf82221e.so(_RNvNtNtCs2ZezlIswSFH_17rustc_codegen_ssa4back4link11link_binary+0x586) [0x7ffff62e2da2]
/home/noah/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-9c23edfdcf82221e.so(_RNvMNtCs6PtJWl2j4pF_15rustc_interface7queriesNtB2_6Linker4link+0x455) [0x7ffff672dc31]
/home/noah/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-9c23edfdcf82221e.so(+0x6124039) [0x7ffff6724039]
/home/noah/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-9c23edfdcf82221e.so(_RINvNtNtCseJswNlh1fGO_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCs6PtJWl2j4pF_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCsj20AIVrSq7d_17rustc_driver_impl12run_compiler0Es_0uE0uE00uEB3C_+0x148) [0x7ffff6564f08]
/home/noah/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-9c23edfdcf82221e.so(+0x5f657f4) [0x7ffff65657f4]
/home/noah/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-9c23edfdcf82221e.so(+0x5f66bf7) [0x7ffff6566bf7]
/nix/store/q4wq65gl3r8fy746v9bbwgx4gzn0r2kl-glibc-2.40-66/lib/libc.so.6(+0x9af08) [0x7ffff029af08]
/nix/store/q4wq65gl3r8fy746v9bbwgx4gzn0r2kl-glibc-2.40-66/lib/libc.so.6(+0x1230ac) [0x7ffff03230ac]

note: we would appreciate a report at https://github.com/rust-lang/rust
error: could not compile `quote` (lib)

Caused by:
  process didn't exit successfully: `/home/noah/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name quote --edition=2018 /home/noah/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/quote-1.0.40/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=238 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="proc-macro"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("default", "proc-macro"))' -C metadata=f3ea2777483e0cff -C extra-filename=-633ca24bad203381 --out-dir /home/noah/projects/rust-bug/target/debug/deps -L dependency=/home/noah/projects/rust-bug/target/debug/deps --extern proc_macro2=/home/noah/projects/rust-bug/target/debug/deps/libproc_macro2-7d83e77cb55998ce.rmeta --cap-lints allow` (signal: 7, SIGBUS: access to undefined memory)
warning: build failed, waiting for other jobs to finish...

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.O-NixOSOperating system: NixOS, https://nixos.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions