Skip to content

cfi: llvm error: !dbg attachment points at wrong subprogram for function #114188

Closed
@matthiaskrgr

Description

@matthiaskrgr

I tried this code:
rustc -Zsanitizer=cfi -Clto --edition=2021 -Cdebuginfo=2 -Copt-level=2 treereduce.out

trait repeat<A> { fn get(&self) -> A; }

impl<A:Clone + 'static> repeat<A> for Box<A> {
    fn get(&self) -> A {
        (**self).clone()
    }
}

fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<dyn repeat<A>+'static> {
    Box::new(v) as Box<dyn repeat<A>+'static> // No
}

pub fn main() {
    let x = 3;
    let y = repeater(Box::new(x));
    assert_eq!(x, y.get());
}

I expected to see this happen: explanation

Instead, this happened: explanation

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (500647fd8 2023-07-27)
binary: rustc
commit-hash: 500647fd8138cc09e87edb08d62f81654fbf6ef8
commit-date: 2023-07-27
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5
Backtrace

!dbg attachment points at wrong subprogram for function
!962 = distinct !DISubprogram(name: "main", linkageName: "_ZN10treereduce4main17h2a214c6e9954fc2eE", scope: !932, file: !930, line: 17, type: !139, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized | DISPFlagMainSubprogram, unit: !33, templateParams: !14, retainedNodes: !963)
ptr @_ZN10treereduce4main17h2a214c6e9954fc2eE.cfi
  call void @llvm.dbg.value(metadata ptr %11, metadata !937, metadata !DIExpression()), !dbg !944
!944 = !DILocation(line: 0, scope: !929)
!929 = distinct !DISubprogram(name: "get<i32>", linkageName: "_ZN74_$LT$alloc..boxed..Box$LT$A$GT$$u20$as$u20$treereduce..repeat$LT$A$GT$$GT$3get17h6c933bd67eae062eE", scope: !931, file: !930, line: 8, type: !933, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !33, templateParams: !938, retainedNodes: !936)
!929 = distinct !DISubprogram(name: "get<i32>", linkageName: "_ZN74_$LT$alloc..boxed..Box$LT$A$GT$$u20$as$u20$treereduce..repeat$LT$A$GT$$GT$3get17h6c933bd67eae062eE", scope: !931, file: !930, line: 8, type: !933, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !33, templateParams: !938, retainedNodes: !936)
!dbg attachment points at wrong subprogram for function
!962 = distinct !DISubprogram(name: "main", linkageName: "_ZN10treereduce4main17h2a214c6e9954fc2eE", scope: !932, file: !930, line: 17, type: !139, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized | DISPFlagMainSubprogram, unit: !33, templateParams: !14, retainedNodes: !963)
ptr @_ZN10treereduce4main17h2a214c6e9954fc2eE.cfi
  call void @llvm.dbg.value(metadata ptr %11, metadata !937, metadata !DIExpression()), !dbg !944
!944 = !DILocation(line: 0, scope: !929)
!929 = distinct !DISubprogram(name: "get<i32>", linkageName: "_ZN74_$LT$alloc..boxed..Box$LT$A$GT$$u20$as$u20$treereduce..repeat$LT$A$GT$$GT$3get17h6c933bd67eae062eE", scope: !931, file: !930, line: 8, type: !933, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !33, templateParams: !938, retainedNodes: !936)
!929 = distinct !DISubprogram(name: "get<i32>", linkageName: "_ZN74_$LT$alloc..boxed..Box$LT$A$GT$$u20$as$u20$treereduce..repeat$LT$A$GT$$GT$3get17h6c933bd67eae062eE", scope: !931, file: !930, line: 8, type: !933, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !33, templateParams: !938, retainedNodes: !936)
rustc: /home/matthias/vcs/github/rust_debug_assertions/src/llvm-project/llvm/lib/CodeGen/LexicalScopes.cpp:178: llvm::LexicalScope *llvm::LexicalScopes::getOrCreateRegularScope(const llvm::DILocalScope *): Assertion `cast<DISubprogram>(Scope)->describes(&MF->getFunction())' failed.
[1]    1007986 IOT instruction  ~/.rustup/toolchains/local-debug-assertions/bin/rustc -Zsanitizer=cfi -Clto

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.PG-exploit-mitigationsProject group: Exploit mitigationsrequires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions