Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Stack overflow in rustc #86556

Closed
vcfxb opened this issue Jun 22, 2021 · 3 comments
Closed

Stack overflow in rustc #86556

vcfxb opened this issue Jun 22, 2021 · 3 comments
Labels
C-bug Category: This is a bug.

Comments

@vcfxb
Copy link
Contributor

vcfxb commented Jun 22, 2021

I'm running into a stack overflow in issue in rustc and I think it's related to macro, but I'm not sure. I copied the pertinent files from my project and reproduced the issue in this repository.

I expect this to compile without issue when I run cargo build (or at least give me a type error if there is one).
Instead, rustc overflows stack on stable, beta, and nightly.

Stable:

$ RUST_BACKTRACE=1 cargo +stable build
   Compiling rustc-stack-overflow v0.1.0 (/home/antonia/Desktop/Projects/rustc-stack-overflow)

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
error: could not compile `rustc-stack-overflow`

Caused by:
  process didn't exit successfully: `rustc --crate-name rustc_stack_overflow --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=20441d2a475a112e -C extra-filename=-20441d2a475a112e --out-dir /home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/deps -C incremental=/home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/incremental -L dependency=/home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/deps --extern graphql_client=/home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/deps/libgraphql_client-63af0a9b9458de3b.rlib` (signal: 6, SIGABRT: process abort signal)

Beta:

$ RUST_BACKTRACE=1 cargo +beta build
   Compiling rustc-stack-overflow v0.1.0 (/home/antonia/Desktop/Projects/rustc-stack-overflow)

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
error: could not compile `rustc-stack-overflow`

Caused by:
  process didn't exit successfully: `rustc --crate-name rustc_stack_overflow --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=8cf59a22ee7dc950 -C extra-filename=-8cf59a22ee7dc950 --out-dir /home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/deps -C incremental=/home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/incremental -L dependency=/home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/deps --extern graphql_client=/home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/deps/libgraphql_client-ab1a22904b6ecf9a.rlib` (signal: 6, SIGABRT: process abort signal)

Nightly:

$ RUST_BACKTRACE=1 cargo +nightly build
   Compiling rustc-stack-overflow v0.1.0 (/home/antonia/Desktop/Projects/rustc-stack-overflow)

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
error: could not compile `rustc-stack-overflow`

Caused by:
  process didn't exit successfully: `rustc --crate-name rustc_stack_overflow --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=2d8f35c6342eed3a -C extra-filename=-2d8f35c6342eed3a --out-dir /home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/deps -C incremental=/home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/incremental -L dependency=/home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/deps --extern graphql_client=/home/antonia/Desktop/Projects/rustc-stack-overflow/target/debug/deps/libgraphql_client-cf5984b918c1a8e3.rlib` (signal: 6, SIGABRT: process abort signal)

Meta

rustc --version --verbose:

$ rustc --version --verbose
rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1
@syvb
Copy link
Contributor

syvb commented Jun 22, 2021

It seems like the issue is originating from a procedural macro in graphql_query_derive (which gets run in the same thread as the compiler itself). Here's a sample of the (very long) backtrace I get when running this under LLDB -- it seems there is a 5 stack frame long cycle that just keeps repeating:

    frame #46309: 0x00007fffe73d3610 libgraphql_query_derive-e699b29ed02c3f32.so`core::iter::traits::iterator::Iterator::try_fold::hf0f1ad64d5839f0c(self=0x00007fffee0ce468, init=<unavailable>, f=closure-0 @ 0x00007fffee0ce360) at iterator.rs:1972:21
    frame #46310: 0x00007fffe73d3307 libgraphql_query_derive-e699b29ed02c3f32.so`core::iter::traits::iterator::Iterator::any::h30537ca8990508c8(self=0x00007fffee0ce468, f=closure-0 @ 0x00007fffee0ce428) at iterator.rs:2264:9
    frame #46311: 0x00007fffe737e826 libgraphql_query_derive-e699b29ed02c3f32.so`graphql_client_codegen::inputs::GqlInput::contains_type_without_indirection::hfae0d0d490c7b02a(self=0x00007fffe4c65c68, context=0x00007fffee3e9510, type_name=(data_ptr = "bonus_attendances_bool_exp", length = 26)) at inputs.rs:38:9
    frame #46312: 0x00007fffe737e94b libgraphql_query_derive-e699b29ed02c3f32.so`graphql_client_codegen::inputs::GqlInput::contains_type_without_indirection::_$u7b$$u7b$closure$u7d$$u7d$::h38de0a1854fa8225(field=0x00007fffe7d51b50) at inputs.rs:54:17
    frame #46313: 0x00007fffe7383bcd libgraphql_query_derive-e699b29ed02c3f32.so`core::iter::traits::iterator::Iterator::any::check::_$u7b$$u7b$closure$u7d$$u7d$::ha1f7fcd0f28fbf84((null)=<unavailable>, x=0x00007fffe7d51b50) at iterator.rs:2260:20
    frame #46314: 0x00007fffe73d3610 libgraphql_query_derive-e699b29ed02c3f32.so`core::iter::traits::iterator::Iterator::try_fold::hf0f1ad64d5839f0c(self=0x00007fffee0ce688, init=<unavailable>, f=closure-0 @ 0x00007fffee0ce580) at iterator.rs:1972:21
    frame #46315: 0x00007fffe73d3307 libgraphql_query_derive-e699b29ed02c3f32.so`core::iter::traits::iterator::Iterator::any::h30537ca8990508c8(self=0x00007fffee0ce688, f=closure-0 @ 0x00007fffee0ce648) at iterator.rs:2264:9
    frame #46316: 0x00007fffe737e826 libgraphql_query_derive-e699b29ed02c3f32.so`graphql_client_codegen::inputs::GqlInput::contains_type_without_indirection::hfae0d0d490c7b02a(self=0x00007fffe4c51c10, context=0x00007fffee3e9510, type_name=(data_ptr = "bonus_attendances_bool_exp", length = 26)) at inputs.rs:38:9
    frame #46317: 0x00007fffe737e94b libgraphql_query_derive-e699b29ed02c3f32.so`graphql_client_codegen::inputs::GqlInput::contains_type_without_indirection::_$u7b$$u7b$closure$u7d$$u7d$::h38de0a1854fa8225(field=0x00007fffed7cee98) at inputs.rs:54:17
    frame #46318: 0x00007fffe7383bcd libgraphql_query_derive-e699b29ed02c3f32.so`core::iter::traits::iterator::Iterator::any::check::_$u7b$$u7b$closure$u7d$$u7d$::ha1f7fcd0f28fbf84((null)=<unavailable>, x=0x00007fffed7cee98) at iterator.rs:2260:20
    frame #46319: 0x00007fffe73d3610 libgraphql_query_derive-e699b29ed02c3f32.so`core::iter::traits::iterator::Iterator::try_fold::hf0f1ad64d5839f0c(self=0x00007fffee0ce8a8, init=<unavailable>, f=closure-0 @ 0x00007fffee0ce7a0) at iterator.rs:1972:21

@vcfxb
Copy link
Contributor Author

vcfxb commented Jun 23, 2021

Oh that's very helpful, thank you! This seems to be an issue with that procedural macro in that case. I made an issue on that library. It would be helpful in my opinion if the compiler limited the recursion and printed a more detailed error message than just stating that rustc had a stack overflow.

@nagisa
Copy link
Member

nagisa commented Jun 23, 2021

That would be a…

Duplicate of #56058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants