Skip to content

ice: cfi: LLVM ERROR with polymorphic paths #112376

Open
@matthiaskrgr

Description

@matthiaskrgr

Code

from ufcs-polymorphic-path.rs
rustc ufcs-polymorphic-paths.rs -Copt-level=3 -Cdebuginfo=2 -Clto -Zsanitizer=cfi

use std::borrow::{Cow, ToOwned};
use std::default::Default;

pub struct XorShiftRng;
impl Rng for XorShiftRng {}
pub trait Rng {}
pub trait Rand: Default + Sized {
    fn rand<R: Rng>(_rng: &mut R) -> Self { Default::default() }
}
impl Rand for i32 { }

pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
    fn into_cow(self) -> Cow<'a, B>;
}

impl<'a> IntoCow<'a, str> for String {
    fn into_cow(self) -> Cow<'a, str> {
        Cow::Owned(self)
    }
}

#[derive(PartialEq, Eq)]
struct Newt<T>(T);

fn eq<T: Eq>(a: T, b: T) -> bool { a == b }


trait Size: Sized {
    fn size() -> usize { std::mem::size_of::<Self>() }
}
impl<T> Size for T {}



#[derive(PartialEq, Eq)]
struct Foo<T>(T);


macro_rules! tests {
    ($($expr:expr, $ty:ty, ($($test:expr),*);)+) => (pub fn main() {$({
        static S: $ty = $expr;
        assert!(eq(S($($test),*), $expr($($test),*)));
    })+})
}

tests! {
    <Vec<()>>::with_capacity, fn(usize) -> Vec<()>, (5);  
}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (e6d4725c7 2023-06-05)
binary: rustc
commit-hash: e6d4725c76f3b526c74454bc51afdf6daf133506
commit-date: 2023-06-05
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.4

Error output

-
Backtrace

!dbg attachment points at wrong subprogram for function
!199 = distinct !DISubprogram(name: "main", linkageName: "_ZN22ufcs_polymorphic_paths4main17h5fab3a21c907a36eE", scope: !14, file: !15, line: 40, type: !195, scopeLine: 40, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized | DISPFlagMainSubprogram, unit: !8, templateParams: !46, retainedNodes: !46)
ptr @_ZN22ufcs_polymorphic_paths4main17h5fab3a21c907a36eE.cfi
  call void @llvm.dbg.declare(metadata ptr undef, metadata !232, metadata !DIExpression()), !dbg !236
!236 = !DILocation(line: 671, column: 46, scope: !233, inlinedAt: !237)
!238 = distinct !DISubprogram(name: "with_capacity<()>", linkageName: "_ZN5alloc3vec12Vec$LT$T$GT$13with_capacity17h0185b499b8c3601eE", scope: !19, file: !206, line: 478, type: !17, scopeLine: 478, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !8, templateParams: !41, declaration: !207, retainedNodes: !239)
!238 = distinct !DISubprogram(name: "with_capacity<()>", linkageName: "_ZN5alloc3vec12Vec$LT$T$GT$13with_capacity17h0185b499b8c3601eE", scope: !19, file: !206, line: 478, type: !17, scopeLine: 478, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !8, templateParams: !41, declaration: !207, retainedNodes: !239)
!dbg attachment points at wrong subprogram for function
!199 = distinct !DISubprogram(name: "main", linkageName: "_ZN22ufcs_polymorphic_paths4main17h5fab3a21c907a36eE", scope: !14, file: !15, line: 40, type: !195, scopeLine: 40, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized | DISPFlagMainSubprogram, unit: !8, templateParams: !46, retainedNodes: !46)
ptr @_ZN22ufcs_polymorphic_paths4main17h5fab3a21c907a36eE.cfi
  call void @llvm.dbg.declare(metadata ptr undef, metadata !232, metadata !DIExpression()), !dbg !236
!236 = !DILocation(line: 671, column: 46, scope: !233, inlinedAt: !237)
!238 = distinct !DISubprogram(name: "with_capacity<()>", linkageName: "_ZN5alloc3vec12Vec$LT$T$GT$13with_capacity17h0185b499b8c3601eE", scope: !19, file: !206, line: 478, type: !17, scopeLine: 478, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !8, templateParams: !41, declaration: !207, retainedNodes: !239)
!238 = distinct !DISubprogram(name: "with_capacity<()>", linkageName: "_ZN5alloc3vec12Vec$LT$T$GT$13with_capacity17h0185b499b8c3601eE", scope: !19, file: !206, line: 478, type: !17, scopeLine: 478, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !8, templateParams: !41, declaration: !207, retainedNodes: !239)
LLVM ERROR: Broken module found, compilation aborted!

Metadata

Metadata

Assignees

Labels

A-control-flow-integrityArea: Control Flow Integrity (CFI) security mitigationA-sanitizersArea: Sanitizers for correctness and code qualityC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️PG-exploit-mitigationsProject group: Exploit mitigationsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-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