rust-lang / rust-lang/rust

llvm error: cfi: `Assertion `cast<DISubprogram>(Scope)->describes(&MF->getFunction())`

Open
#119,951 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-control-flow-integrity A-sanitizers C-bug I-crash I-ICE PG-exploit-mitigations requires-debug-assertions T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

snippet:

use std::sync::atomic::Ordering::*;
use std::sync::atomic::{fence, AtomicUsize};
use std::thread::spawn;

fn static_atomic(val: usize) -> &'static AtomicUsize {
    let ret = Box::leak(Box::new(AtomicUsize::new(val)));
    ret
}

fn relaxed() -> bool {
    let x = static_atomic(0);

    let j2 = spawn(move || x.load(Relaxed));

    let r2 = j2.join().unwrap();

    r2 == 1
}

fn seq_cst() -> bool {
    let x = static_atomic(0);

    let j3 = spawn(move || x.load(SeqCst));

    let r3 = j3.join().unwrap();

    r3 == 1
}

fn initialization_write(add_fence: bool) -> bool {
    let x = static_atomic(11);

    let j2 = spawn(move || x.load(Relaxed));

    let r2 = j2.join().unwrap();

    r2 == 11
}

fn assert_once(f: fn() -> bool) {
    assert!(std::iter::repeat_with(|| f()).take(100).any(|x| x));
}

pub fn main() {
    assert_once(relaxed);
    assert_once(seq_cst);
    assert_once(|| initialization_write(false));
}


Version information

rustc 1.77.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.77.0-dev
LLVM version: 17.0.6

Command:
/home/matthias/.rustup/toolchains/local-debug-assertions/bin/rustc -Zmir-opt-level=3 -Cdebuginfo=2 -Copt-level=3 -Zsanitizer=cfi -Ccodegen-units=1 -Clto -ocodegen -Zsanitizer-cfi-normalize-integers --edition=2015

Program output

warning: unused import: `fence`
 --> /tmp/icemaker_global_tempdir.18GTkKSaGL4b/rustc_testrunner_tmpdir_reporting.PLKsBwe60BMh/mvce.rs:2:25
  |
2 | use std::sync::atomic::{fence, AtomicUsize};
  |                         ^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused variable: `add_fence`
  --> /tmp/icemaker_global_tempdir.18GTkKSaGL4b/rustc_testrunner_tmpdir_reporting.PLKsBwe60BMh/mvce.rs:30:25
   |
30 | fn initialization_write(add_fence: bool) -> bool {
   |                         ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_add_fence`
   |
   = note: `#[warn(unused_variables)]` on by default

inlinable function call in a function with debug info must have a !dbg location
  %34 = tail call noundef zeroext i1 @_ZN4core3ops8function6FnOnce9call_once17h0a5cef41d9043f5eE(), !noalias !6817
inlinable function call in a function with debug info must have a !dbg location
  %34 = tail call noundef zeroext i1 @_ZN4core3ops8function6FnOnce9call_once17h0a5cef41d9043f5eE(), !noalias !6816
LLVM ERROR: Broken module found, compilation aborted!

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 by reproducing the failure from the provided weak.rs snippet with the exact rustc command and flags, especially debuginfo, LTO, CFI, and MIR optimization. Inspect the LLVM diagnostic about missing !dbg locations and the cfi assertion. Done means the reproducer compiles without the broken-module error under the reported configuration.

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.