Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matthiaskrgr opened this issue Jul 28, 2023 · 2 comments
Closed
Assignees
Labels
C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. PG-exploit-mitigations Project group: Exploit mitigations requires-nightly This issue requires a nightly compiler in some way.

Comments

@matthiaskrgr
Copy link
Member

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

@matthiaskrgr matthiaskrgr added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. PG-exploit-mitigations Project group: Exploit mitigations labels Jul 28, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 28, 2023
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 29, 2023
@Noratrieb
Copy link
Member

@rcvalle

@rcvalle
Copy link
Member

rcvalle commented Aug 9, 2023

This seems to have been fixed in #113593.

@rcvalle rcvalle closed this as completed Aug 9, 2023
@rcvalle rcvalle self-assigned this Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. PG-exploit-mitigations Project group: Exploit mitigations requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

No branches or pull requests

4 participants