Skip to content

ICE: CFI dies on #[repr(transparent)] on a parameterized ADT (e.g. ManuallyDrop). #106230

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

Closed
maurer opened this issue Dec 28, 2022 · 2 comments · Fixed by #106232
Closed

ICE: CFI dies on #[repr(transparent)] on a parameterized ADT (e.g. ManuallyDrop). #106230

maurer opened this issue Dec 28, 2022 · 2 comments · Fixed by #106232
Assignees
Labels
C-bug Category: This is a bug. 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.

Comments

@maurer
Copy link
Contributor

maurer commented Dec 28, 2022

I've got a fix for this that I'll be uploading in a minute or two, I'm filing the issue to claim an issue number for the test.

Code

#[repr(transparent)]
pub struct Thin<T> (T);
pub fn foo() -> Thin<u8> {
  Thin(0)
}

Meta

rustc --version --verbose:

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

Error output

rustc -Zsanitizer=cfi -C lto --crate-type=rlib input.rs

error: internal compiler error: compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs:798:13: transform_ty: unexpected `Param(T/#0)`

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.68.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z sanitizer=cfi -C lto --crate-type rlib

query stack during panic:
end of query stack
error: aborting due to previous error

@maurer maurer added C-bug Category: This is a bug. 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. labels Dec 28, 2022
@maurer
Copy link
Contributor Author

maurer commented Dec 28, 2022

@rustbot claim

jyn514 added a commit to jyn514/rust that referenced this issue Dec 30, 2022
CFI: Monomorphize transparent ADTs before typeid

Monomorphise `#[repr(transparent)]` parameterized ADTs before turning them into an Itanium mangled String.

`#[repr(transparent)]` ADTs currently use the single field to represent them in their CFI type ID to ensure that they are compatible. However, if that type involves a type parameter instantiated at the ADT level, as in `ManuallyDrop`, this will currently ICE as the `Parameter` type cannot be mangled. Since this happens at lowering time, it should always be concrete after substitution.

Fixes rust-lang#106230
jyn514 added a commit to jyn514/rust that referenced this issue Dec 31, 2022
CFI: Monomorphize transparent ADTs before typeid

Monomorphise `#[repr(transparent)]` parameterized ADTs before turning them into an Itanium mangled String.

`#[repr(transparent)]` ADTs currently use the single field to represent them in their CFI type ID to ensure that they are compatible. However, if that type involves a type parameter instantiated at the ADT level, as in `ManuallyDrop`, this will currently ICE as the `Parameter` type cannot be mangled. Since this happens at lowering time, it should always be concrete after substitution.

Fixes rust-lang#106230
compiler-errors added a commit to compiler-errors/rust that referenced this issue Dec 31, 2022
CFI: Monomorphize transparent ADTs before typeid

Monomorphise `#[repr(transparent)]` parameterized ADTs before turning them into an Itanium mangled String.

`#[repr(transparent)]` ADTs currently use the single field to represent them in their CFI type ID to ensure that they are compatible. However, if that type involves a type parameter instantiated at the ADT level, as in `ManuallyDrop`, this will currently ICE as the `Parameter` type cannot be mangled. Since this happens at lowering time, it should always be concrete after substitution.

Fixes rust-lang#106230
@bors bors closed this as completed in fb2c27d Dec 31, 2022
@rcvalle
Copy link
Member

rcvalle commented Jan 14, 2023

This seems to be a duplicate of #100772.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants