rust-lang / rust-lang/rust

rustc segfaults on `global_asm!("jz [foo]")` on x86_64-pc-windows-msvc (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

Open
#135,362 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-LLVM C-bug I-crash O-windows O-windows-msvc T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
use std::arch::global_asm;
global_asm!("jz [0x00547274]");

No other lines of code, no dependencies. Other code (also with global_asm!) builds fine.

Meta

rustc --version --verbose:

rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: x86_64-pc-windows-msvc
release: 1.84.0
LLVM version: 19.1.5
Error output
PS C:\Users\Benni\rustccrash> cargo build
   Compiling rustccrash v0.1.0 (C:\Users\Benni\rustccrash)
error: could not compile `rustccrash` (lib)

Caused by:
  process didn't exit successfully: `C:\Users\Benni\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name rustccrash --edition=2021 src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=241 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs) --check-cfg "cfg(feature, values())" -C metadata=c9c8a2735a047fdf -C extra-filename=-c9c8a2735a047fdf --out-dir 
C:\Users\Benni\rustccrash\target\debug\deps -C incremental=C:\Users\Benni\rustccrash\target\debug\incremental -L dependency=C:\Users\Benni\rustccrash\target\debug\deps` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal example in src/lib.rs and reproduce the crash using cargo build on x86_64-pc-windows-msvc with the shown global_asm! invocation. Trace the compiler's handling of this assembly until the access violation is identified; done means the example no longer segfaults and a regression test covers it.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.