Skip to content

Compiler null dereference when there are conflicting asm labels #74262

Closed
@addrianyy

Description

@addrianyy

Code

#![feature(asm)]

#[inline(always)]
fn f() {
    unsafe {
        asm!("test: nop");
    }
}

fn main() {
    f();
    f();
}

Meta

rustc 1.46.0-nightly (346aec9b0 2020-07-11)
binary: rustc
commit-hash: 346aec9b02f3c74f3fce97fd6bda24709d220e49
commit-date: 2020-07-11
host: x86_64-pc-windows-msvc
release: 1.46.0-nightly
LLVM version: 10.0

Error output

error: invalid symbol redefinition
 --> .\crash.rs:6:15
  |
6 |         asm!("test: nop");
  |               ^
  |
note: instantiated into assembly here
 --> <inline asm>:2:2
  |
2 |     test: nop
  |     ^
[crash due to null dereference]

Details

This bug only happens when compiling for Windows target with debug information. Command to reproduce crash:

rustc crash.rs --target x86_64-pc-windows-msvc -g

It was identified by eddyb that crash happens in LLVM function WinCOFFObjectWriter::assignFileOffsets.

Metadata

Metadata

Assignees

Labels

A-inline-assemblyArea: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.F-asm`#![feature(asm)]` (not `llvm_asm`)I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.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