You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rustc overflow its stack when using impl Trait and the struct containing the function itself #69096
A-codegenArea: Code generationA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
(gdb) bt
#00x00007ffff6966e15 in hashbrown::map::RawEntryBuilder<K,V,S>::from_key_hashed_nocheck () from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-154376714aaee7fe.so
#10x00007ffff6d36f5ein rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-154376714aaee7fe.so
#20x00007ffff6a6a0c3in rustc::ty::structural_impls::fold_list() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-154376714aaee7fe.so
#30x00007ffff6d00036in rustc::ty::normalize_erasing_regions::<impl rustc::ty::context::TyCtxt>::normalize_erasing_late_bound_regions() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-154376714aaee7fe.so
#40x00007ffff6fd048ain rustc::ty::print::obsolete::DefPathBasedNames::push_type_name() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-154376714aaee7fe.so
#50x00007ffff6fd2d39in rustc::ty::print::obsolete::DefPathBasedNames::push_generic_params() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-154376714aaee7fe.so
#60x00007ffff6fd1739in rustc::ty::print::obsolete::DefPathBasedNames::push_type_name() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-154376714aaee7fe.so
#70x00007ffff6fd2d39in rustc::ty::print::obsolete::DefPathBasedNames::push_generic_params() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-154376714aaee7fe.so
#80x00007ffff6fd1739in rustc::ty::print::obsolete::DefPathBasedNames::push_type_name() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-154376714aaee7fe.so
#90x00007ffff6fd2d39in rustc::ty::print::obsolete::DefPathBasedNames::push_generic_params() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-154376714aaee7fe.so
...
#1820170x00007ffff6eddcce in rustc::ty::print::obsolete::DefPathBasedNames::push_type_name() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820180x00007ffff6eded19in rustc::ty::print::obsolete::DefPathBasedNames::push_generic_params() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820190x00007ffff50016fcin <rustc_target::abi::TyLayout<&rustc::ty::TyS> as rustc_codegen_llvm::type_of::LayoutLlvmExt>::llvm_type() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820200x00007ffff4eb5188in rustc_codegen_ssa::mir::operand::OperandRef<V>::new_zst() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820210x00007ffff4fbd16din rustc_codegen_ssa::mir::codegen_mir::{{closure}}() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820220x00007ffff4fe5216in <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::fold () from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820230x00007ffff4fb23f2in <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter () from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820240x00007ffff4fbc205in rustc_codegen_ssa::mir::codegen_mir() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820250x00007ffff4ef2bfcin <rustc::mir::mono::MonoItemas rustc_codegen_ssa::mono_item::MonoItemExt>::define() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820260x00007ffff4e6859ain rustc_codegen_llvm::base::compile_codegen_unit::module_codegen() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820270x00007ffff4f1c8b0in rustc::dep_graph::graph::DepGraph::with_task() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820280x00007ffff4e68164in rustc_codegen_llvm::base::compile_codegen_unit() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820290x00007ffff4fec61fin rustc_codegen_ssa::base::codegen_crate() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820300x00007ffff4f297b5in <rustc_codegen_llvm::LlvmCodegenBackendas rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820310x00007ffff4deecccin rustc_interface::passes::QueryContext::enter() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820320x00007ffff4d120bbin rustc_interface::queries::Queries::ongoing_codegen() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820330x00007ffff4bae7d3in rustc_interface::interface::run_compiler_in_existing_thread_pool() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820340x00007ffff4b664bdin scoped_tls::ScopedKey<T>::set() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820350x00007ffff4bd3414in syntax::attr::with_globals() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820360x00007ffff4b9df10in std::sys_common::backtrace::__rust_begin_short_backtrace() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820370x00007ffff44ece67in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:86
#1820380x00007ffff4bb0c36 in core::ops::function::FnOnce::call_once{{vtable-shim}}() from /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-d8719fb60c037747.so
#1820390x00007ffff44b846fin <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once () at /rustc/a1912f2e89b77cfe2a0e64b96f444848fe4e2d49/src/liballoc/boxed.rs:1017
#1820400x00007ffff44eb770in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once () at /rustc/a1912f2e89b77cfe2a0e64b96f444848fe4e2d49/src/liballoc/boxed.rs:1017
#182041std::sys_common::thread::start_thread() at src/libstd/sys_common/thread.rs:13
#182042 std::sys::unix::thread::Thread::new::thread_start() at src/libstd/sys/unix/thread.rs:80
#1820430x00007ffff4433fa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
#1820440x00007ffff43534cf in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95(gdb)
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3
So I tried to reproduce the overflow manually by going back to see where it firstly regressed, due to the rust-lang/cargo-bisect-rustc#49.
But couldn't find a working build yet...
The latest (youngest) build I tested now was 1.14.0-nightly, which is from 2016 and I was still able to reproduce the error. Had to add #![feature(conservative_impl_trait)] as impl Trait was experimental back then.
I don't think there is a build (nightly) that will compile this code correctly.
❯ rustc main.rs
warning: field is never used: `f`, #[warn(dead_code)] on by default
--> main.rs:13:5
|
13 | f: F,
| ^^^^
thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
[1] 77863 abort rustc main.rs
@Centril Any chance you forgot to add pub? godbolt is always in library mode IIRC so there might not be enough codegen to reach the infinite recursion (and maybe we changed the rules when some things are codegen'd, especially around impl Trait)
PSA: seeing <No assembly generated> in godbolt is a big warning sign.
It means you're accidentally not testing anything (at least codegen-wise).
Making mainpub fn on 1.29.0 (keep in mind, godbolt always compiles a lib crate, not a bin one) results in this: https://godbolt.org/z/icX4pU (thread 'main' has overflowed its stack).
This fits with #69096 (comment), and I wish godbolt had nightly versions matching stable ones, or at least a way to pass env vars (because there's no real protection against abusing stable compilers).
A-codegenArea: Code generationA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
Activity
tesuji commentedon Feb 12, 2020
Infinite loop I think:
Centril commentedon Feb 13, 2020
nikomatsakis commentedon Feb 13, 2020
@rustbot ping icebreakers-cleanup-crew
There is already a minimal example here, but it'd be great to figure out the PR (or at least nightly) that caused it regress.
rustbot commentedon Feb 13, 2020
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3
cc @AminArria @chrissimpkins @DutchGhost @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @matheus-consoli @mental32 @Noah-Kennedy @pard68 @pierreN @robjtede @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke
nikomatsakis commentedon Feb 13, 2020
Tagging as P-high since this is a regression, though it might be considered P-medium otherwise (not an active soundness hole, for example).
3 remaining items
eddyb commentedon Feb 13, 2020
That suggests that you're using a Cargo too new or somehow back-compat logic was removed (or never present?) in Cargo (not sure what our policy is).
You need an older Cargo to go back past the addition of
--json.But also it would be nice if Cargo didn't need to be involved in the bisection process, because it IMO unnecessarily complicates it.
chrissimpkins commentedon Feb 13, 2020
rust-lang/cargo-bisect-rustc#49
HallerPatrick commentedon Feb 13, 2020
So I tried to reproduce the overflow manually by going back to see where it firstly regressed, due to the rust-lang/cargo-bisect-rustc#49.
But couldn't find a working build yet...
The latest (youngest) build I tested now was 1.14.0-nightly, which is from 2016 and I was still able to reproduce the error. Had to add
#![feature(conservative_impl_trait)]asimpl Traitwas experimental back then.I don't think there is a build (nightly) that will compile this code correctly.
❯ rustc main.rs
Meta
rustc --version --verbose:eddyb commentedon Feb 13, 2020
@Centril Any chance you forgot to add
pub? godbolt is always in library mode IIRC so there might not be enough codegen to reach the infinite recursion (and maybe we changed the rules when some things are codegen'd, especially aroundimpl Trait)Centril commentedon Feb 13, 2020
@eddyb I copy pasted the code into godbolt so I didn't add
pub.eddyb commentedon Feb 15, 2020
Just checked, this is what that looks like: https://godbolt.org/z/vc3D35
PSA: seeing
<No assembly generated>ingodboltis a big warning sign.It means you're accidentally not testing anything (at least codegen-wise).
Making
mainpub fnon 1.29.0 (keep in mind, godbolt always compiles alibcrate, not abinone) results in this: https://godbolt.org/z/icX4pU (thread 'main' has overflowed its stack).And it's the same on 1.26.0 (first stable w/
-> impl Trait): https://godbolt.org/z/WyuNsB.This fits with #69096 (comment), and I wish godbolt had nightly versions matching stable ones, or at least a way to pass env vars (because there's no real protection against abusing stable compilers).
pnkfelix commentedon May 6, 2020
nominating for discussion as part of attempt to burn down set of unassigned P-high issues at an otherwise light triage meeting.
pnkfelix commentedon May 7, 2020
discussed at T-compiler meeting. Reprioritizing as P-medium, since its not a true regression and not an active soundness hole.
jyn514 commentedon Jul 7, 2021
Triage: this now compiles and runs successfully.