rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.14k stars 12.56k forks source link

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

Open tmiasko opened 1 week ago

tmiasko commented 1 week ago

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 ::intern_ty () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so (gdb) bt #0 0x00007ffff61a67d4 in ::intern_ty () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #1 0x00007ffff625be58 in >::super_fold_with::> () 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>::try_fold_with::> () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #3 0x00007ffff625bb48 in >::super_fold_with::> () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #4 0x00007ffff625bc31 in >::super_fold_with::> () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #5 0x00007ffff6275014 in ::ty () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #6 0x00007ffff50ae576 in ::check_variant_for_ffi () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #7 0x00007ffff50af1bf in ::check_type_for_ffi () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #8 0x00007ffff50ae5bc in ::check_variant_for_ffi () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #9 0x00007ffff50af1bf in ::check_type_for_ffi () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #10 0x00007ffff50ae5bc in ::check_variant_for_ffi () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #11 0x00007ffff50af1bf in ::check_type_for_ffi () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #12 0x00007ffff50ae5bc in ::check_variant_for_ffi () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so #13 0x00007ffff50af1bf in ::check_type_for_ffi () from /home/tm/.rustup/toolchains/stage1/lib/librustc_driver-14c009390c37828b.so ... ```

gurry commented 1 week ago

@rustbot claim