Stack overflow with `clashing_extern_declarations`
Open
Nobody has claimed this yet.
A-lints
C-bug
I-crash
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
Code
#![warn(clashing_extern_declarations)]
#[repr(C)]
struct A<T> {
a: *const A<A<T>>,
t: T,
}
#[repr(C)]
struct B<T> {
b: *const B<B<T>>,
t: T,
}
pub mod x {
extern "C" {
pub fn bar(_: super::A<i32>);
}
}
pub mod y {
extern "C" {
pub fn bar(_: super::B<i32>);
//~^ WARN `bar` redeclared with a different signature
}
}
Affected release channels
- Previous Stable
- Current Stable
- Current Beta
- Current Nightly
Rust Version
stable and nightly
Current error output
Not relevant
Backtrace
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x32b0323)[0x7f20888aa323]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x14420)[0x7f20854a9420]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(_RNvMs3_NtNtCsfYN5AaPO7EC_12rustc_middle2ty7contextNtB5_13CtxtInterners9intern_ty+0x62)[0x7f2086a16112]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x48300d3)[0x7f2089e2a0d3]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x482ff4e)[0x7f2089e29f4e]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x483016a)[0x7f2089e2a16a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(_RNvMsL_NtCsfYN5AaPO7EC_12rustc_middle2tyNtB5_8FieldDef2ty+0x14a)[0x7f2089e285ca]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb949)[0x7f208a5d5949]
### cycle encountered after 8 frames with period 10
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
### recursed 24 times
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
note: rustc unexpectedly overflowed its stack! this is a bug
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the provided reproducer with rustc and examine the intern_ty and FieldDef::ty recursion shown in the backtrace. Done means the example no longer overflows the stack and reports the expected clashing_extern_declarations warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100