Skip to content

stack overflow in ImproperCTypesVisitor::{check_type_for_ffi, check_variant_for_ffi} #130310

@tmiasko

Description

@tmiasko

Code

use std::marker::PhantomData;

#[repr(C)]
struct A<T> {
    a: *const A<A<T>>,
    p: PhantomData<T>,
}

extern "C" {
    fn f(a: *const A<()>);
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.83.0-nightly (adaff5368 2024-09-12)
binary: rustc
commit-hash: adaff5368b0c7b328a0320a218751d65ab1bba97
commit-date: 2024-09-12
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

Error output

error: rustc interrupted by SIGSEGV, printing backtrace
...
note: rustc unexpectedly overflowed its stack! this is a bug
note: maximum backtrace depth reached, frames may have been lost
note: we would appreciate a report at https://github.com/rust-lang/rust
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
note: backtrace dumped due to SIGSEGV! resuming signal
Segmentation fault
Backtrace

0x00007ffff61a67d4 in <rustc_middle::ty::context::CtxtInterners>::intern_ty () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
(gdb) bt
#0  0x00007ffff61a67d4 in <rustc_middle::ty::context::CtxtInterners>::intern_ty () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#1  0x00007ffff625be58 in <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>> () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#2  0x00007ffff639b7e0 in <&rustc_middle::ty::list::RawList<(), rustc_middle::ty::generic_args::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>> ()
   from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#3  0x00007ffff625bb48 in <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>> () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#4  0x00007ffff625bc31 in <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>> () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#5  0x00007ffff6275014 in <rustc_middle::ty::FieldDef>::ty () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#6  0x00007ffff50ae576 in <rustc_lint::types::ImproperCTypesVisitor>::check_variant_for_ffi ()
   from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#7  0x00007ffff50af1bf in <rustc_lint::types::ImproperCTypesVisitor>::check_type_for_ffi ()
   from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#8  0x00007ffff50ae5bc in <rustc_lint::types::ImproperCTypesVisitor>::check_variant_for_ffi ()
   from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#9  0x00007ffff50af1bf in <rustc_lint::types::ImproperCTypesVisitor>::check_type_for_ffi ()
   from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#10 0x00007ffff50ae5bc in <rustc_lint::types::ImproperCTypesVisitor>::check_variant_for_ffi ()
   from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#11 0x00007ffff50af1bf in <rustc_lint::types::ImproperCTypesVisitor>::check_type_for_ffi ()
   from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#12 0x00007ffff50ae5bc in <rustc_lint::types::ImproperCTypesVisitor>::check_variant_for_ffi ()
   from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
#13 0x00007ffff50af1bf in <rustc_lint::types::ImproperCTypesVisitor>::check_type_for_ffi ()
   from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so
...

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.L-improper_ctypesLint: improper_ctypesS-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions