Skip to content

LLVM ERROR: Broken module with -Cdebuginfo=2 -Zsanitizer=cfi -Clto #100783

New issue

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

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

Already on GitHub? # to your account

Open
matthiaskrgr opened this issue Aug 19, 2022 · 7 comments
Open

LLVM ERROR: Broken module with -Cdebuginfo=2 -Zsanitizer=cfi -Clto #100783

matthiaskrgr opened this issue Aug 19, 2022 · 7 comments
Assignees
Labels
A-control-flow-integrity Area: Control Flow Integrity (CFI) security mitigation A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ PG-exploit-mitigations Project group: Exploit mitigations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Aug 19, 2022

Code

./src/test/ui/issues/issue-27901.rs

// run-pass
trait Stream { type Item; }
impl<'a> Stream for &'a str { type Item = u8; }
fn f<'s>(s: &'s str) -> (&'s str, <&'s str as Stream>::Item) {
    (s, 42)
}

fn main() {
    let fx = f as for<'t> fn(&'t str) -> (&'t str, <&'t str as Stream>::Item);
    assert_eq!(fx("hi"), ("hi", 42));
}

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (0b79f758c 2022-08-18)
binary: rustc
commit-hash: 0b79f758c9aa6646606662a6d623a0752286cd17
commit-date: 2022-08-18
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

Error output

rustc ./issue-27901.rs -Cdebuginfo=2 -Zsanitizer=cfi -Clto

inlinable function call in a function with debug info must have a !dbg location
  call void @_ZN11issue_279011f17h923e371f4763f6b8E.cfi(ptr sret({ { ptr, i64 }, i8, [7 x i8] }) %6, ptr align 1 @3, i64 2)
inlinable function call in a function with debug info must have a !dbg location
  call void @_ZN11issue_279011f17h923e371f4763f6b8E.cfi(ptr sret({ { ptr, i64 }, i8, [7 x i8] }) %6, ptr align 1 @3, i64 2)
LLVM ERROR: Broken module found, compilation aborted!
Backtrace

same

@matthiaskrgr matthiaskrgr added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Aug 19, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 22, 2022
@rcvalle
Copy link
Member

rcvalle commented Aug 27, 2022

@rustbot claim

@JohnTitor
Copy link
Member

Triage: This is no longer ICE since today's nightly.
@rustbot labels: +E-needs-test

@rustbot rustbot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 5, 2023
@matthiaskrgr
Copy link
Member Author

I think this is still reproducible:

./tests/ui/associated-types/associated-types-doubleendediterator-object.rs

fn pairwise_sub(mut t: Box<dyn DoubleEndedIterator<Item=isize>>) -> isize {
    let mut result = 0;
    loop {
        let front = t.next();
        let back = t.next_back();
        match (front, back) {
            (Some(f), Some(b)) => { result += b - f; }
            _ => { return result; }
        }
    }
}

fn main() {
    let v = vec![1, 2, 3, 4, 5, 6];
    let r = pairwise_sub(Box::new(v.into_iter()));
    assert_eq!(r, 9);
}

rustc -Zsanitizer-cfi-normalize-integers -Clto -Zsanitizer=cfi -Ccodegen-units=1 -Cdebuginfo=2 -Copt-level=3 ./tests/ui/associated-types/associated-types-doubleendediterator-object.rs


inlinable function call in a function with debug info must have a !dbg location
  %24 = tail call { i64, i64 } @"_ZN103_$LT$alloc..vec..into_iter..IntoIter$LT$T$C$A$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17hf0fad4eb49ef37d8E"(ptr noundef nonnull align 1 %12)
inlinable function call in a function with debug info must have a !dbg location
  %25 = tail call { i64, i64 } @"_ZN103_$LT$alloc..vec..into_iter..IntoIter$LT$T$C$A$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17hf0fad4eb49ef37d8E"(ptr noundef nonnull align 1 %12)
LLVM ERROR: Broken module found, compilation aborted!

@matthiaskrgr matthiaskrgr removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Aug 9, 2023
@Jules-Bertholet
Copy link
Contributor

@rustbot label A-sanitizers

@rustbot rustbot added the A-sanitizers Area: Sanitizers for correctness and code quality label Apr 8, 2024
@1c3t3a
Copy link
Member

1c3t3a commented Nov 1, 2024

I am unable to reproduce this on latest nightly.

@jieyouxu jieyouxu added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Nov 1, 2024
@1c3t3a
Copy link
Member

1c3t3a commented Nov 5, 2024

It seems like this is coming up again in #132615. The example here doesn't throw an error for me though.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 12, 2024
CFI: Append debug location to CFI blocks

Currently we're not appending debug locations to the inserted CFI blocks. This shows up in rust-lang#132615 and rust-lang#100783. This change fixes that by passing down the debug location to the CFI type-test generation and appending it to the blocks.

Credits also belong to `@jakos-sec` who worked with me on this.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 13, 2024
Rollup merge of rust-lang#132702 - 1c3t3a:issue-132615, r=rcvalle

CFI: Append debug location to CFI blocks

Currently we're not appending debug locations to the inserted CFI blocks. This shows up in rust-lang#132615 and rust-lang#100783. This change fixes that by passing down the debug location to the CFI type-test generation and appending it to the blocks.

Credits also belong to `@jakos-sec` who worked with me on this.
@1c3t3a
Copy link
Member

1c3t3a commented Nov 15, 2024

This can be closed as it was fixed in #132702.

antoyo pushed a commit to antoyo/rust that referenced this issue Jan 13, 2025
CFI: Append debug location to CFI blocks

Currently we're not appending debug locations to the inserted CFI blocks. This shows up in rust-lang#132615 and rust-lang#100783. This change fixes that by passing down the debug location to the CFI type-test generation and appending it to the blocks.

Credits also belong to `@jakos-sec` who worked with me on this.
@Noratrieb Noratrieb added the A-control-flow-integrity Area: Control Flow Integrity (CFI) security mitigation label Feb 23, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-control-flow-integrity Area: Control Flow Integrity (CFI) security mitigation A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ PG-exploit-mitigations Project group: Exploit mitigations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

9 participants