Skip to content

hang in parser::diagnostics::expected_one_of_not_found() #124897

New issue

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

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

Already on GitHub? # to your account

Closed
matthiaskrgr opened this issue May 8, 2024 · 6 comments · Fixed by #124930
Closed

hang in parser::diagnostics::expected_one_of_not_found() #124897

matthiaskrgr opened this issue May 8, 2024 · 6 comments · Fixed by #124930
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression.

Comments

@matthiaskrgr
Copy link
Member

Code

I tried this code:

trait TraitA<'a, 'b, 'c> { type AsA; }
trait TraitB<'a, 'b> { type AsB; }
trait TraitC<'a, 'b, 'c> {}
struct X;
struct Y;
struct Z;

fn foo<T>() where for<const N: u8 = { T::<0>::A as u8 + TraitB<'a, 'b, AsB: for<'c> TraitC<'a, 'b, 'c>>::B as u8 }> T: TraitA<'a, AsA: for<'b> TraitB<'a, 'b, AsB: for<'c> TraitC<'a, 'b, 'c>>> {}

fn main() {}

on stable 1.78.0, this checks in 0.02 seconds.
on beta 1.79.0-beta.3, this hangs somewhere in parser::diagnostics::expected_one_of_not_found(), I killed it after 5 minutes of no progress.

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels May 8, 2024
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 8, 2024
@compiler-errors compiler-errors added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label May 8, 2024
@lqd
Copy link
Member

lqd commented May 8, 2024

#124169 cc @compiler-errors

@lqd lqd removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label May 8, 2024
@compiler-errors
Copy link
Member

Sharing the stack would be useful

@matthiaskrgr matthiaskrgr added the E-needs-stack Call for participation: This issue needs a stacktrace. label May 8, 2024
@matthiaskrgr
Copy link
Member Author

🤔 that doesn't really seem to be it

#0  0x00007ffff16a5ebe in ?? () from /usr/lib/libc.so.6
#1  0x00007ffff16ab0e3 in ?? () from /usr/lib/libc.so.6
#2  0x00007ffff7f59911 in std::sys::pal::unix::thread::Thread::join () at library/std/src/sys/pal/unix/thread.rs:272
#3  0x00007ffff69363eb in rustc_driver_impl::run_compiler () from /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-baba34ae40c356f7.so
#4  0x00007ffff693512a in rustc_driver_impl::main () from /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-baba34ae40c356f7.so
#5  0x000055555556dc17 in rustc_main::main ()
#6  0x000055555556dc03 in std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()> ()
#7  0x000055555556dbf9 in <std::rt::lang_start<()>::{closure#0} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} ()
#8  0x00007ffff7f31a7d in core::ops::function::impls::{impl#2}::call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> () at library/core/src/ops/function.rs:284
#9  std::panicking::try::do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> () at library/std/src/panicking.rs:559
#10 std::panicking::try<i32, &(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> () at library/std/src/panicking.rs:523
#11 std::panic::catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> () at library/std/src/panic.rs:149
#12 std::rt::lang_start_internal::{closure#2} () at library/std/src/rt.rs:141
#13 std::panicking::try::do_call<std::rt::lang_start_internal::{closure_env#2}, isize> () at library/std/src/panicking.rs:559
#14 std::panicking::try<isize, std::rt::lang_start_internal::{closure_env#2}> () at library/std/src/panicking.rs:523
#15 std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#2}, isize> () at library/std/src/panic.rs:149
#16 std::rt::lang_start_internal () at library/std/src/rt.rs:141
#17 0x000055555556dd47 in main ()

@compiler-errors
Copy link
Member

You need to switch to like thread 2 or 3 if you're doing this in gdb

@lqd
Copy link
Member

lqd commented May 8, 2024

it's not particularly deep, but it looks downstream of expected_one_of_not_found so I guess this must be it

(gdb) where
#0  0x00007ffff5e3bd36 in _RINvNtNtCs3F8Jha18Tk_4core5slice4sort7recurseTNtNtCstuQ0eX0Bta_5alloc6string6StringjENvYBH_NtNtB6_3cmp10PartialOrd2ltECsas5oqsEyxam_11rustc_parse.llvm.17088249821402055010 ()
   from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#1  0x00007ffff5e3c22e in _RINvNtNtCs3F8Jha18Tk_4core5slice4sort7recurseTNtNtCstuQ0eX0Bta_5alloc6string6StringjENvYBH_NtNtB6_3cmp10PartialOrd2ltECsas5oqsEyxam_11rustc_parse.llvm.17088249821402055010 ()
   from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#2  0x00007ffff5e3c200 in _RINvNtNtCs3F8Jha18Tk_4core5slice4sort7recurseTNtNtCstuQ0eX0Bta_5alloc6string6StringjENvYBH_NtNtB6_3cmp10PartialOrd2ltECsas5oqsEyxam_11rustc_parse.llvm.17088249821402055010 ()
   from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#3  0x00007ffff5e3c200 in _RINvNtNtCs3F8Jha18Tk_4core5slice4sort7recurseTNtNtCstuQ0eX0Bta_5alloc6string6StringjENvYBH_NtNtB6_3cmp10PartialOrd2ltECsas5oqsEyxam_11rustc_parse.llvm.17088249821402055010 ()
   from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#4  0x00007ffff5e3c22e in _RINvNtNtCs3F8Jha18Tk_4core5slice4sort7recurseTNtNtCstuQ0eX0Bta_5alloc6string6StringjENvYBH_NtNtB6_3cmp10PartialOrd2ltECsas5oqsEyxam_11rustc_parse.llvm.17088249821402055010 ()
   from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#5  0x00007ffff5e3c200 in _RINvNtNtCs3F8Jha18Tk_4core5slice4sort7recurseTNtNtCstuQ0eX0Bta_5alloc6string6StringjENvYBH_NtNtB6_3cmp10PartialOrd2ltECsas5oqsEyxam_11rustc_parse.llvm.17088249821402055010 ()
   from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#6  0x00007ffff5e3c200 in _RINvNtNtCs3F8Jha18Tk_4core5slice4sort7recurseTNtNtCstuQ0eX0Bta_5alloc6string6StringjENvYBH_NtNtB6_3cmp10PartialOrd2ltECsas5oqsEyxam_11rustc_parse.llvm.17088249821402055010 ()
   from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#7  0x00007ffff5d6facd in _RNvMs7_NtNtCsas5oqsEyxam_11rustc_parse6parser11diagnosticsNtB7_6Parser25expected_one_of_not_found.llvm.1155081324615980392 ()
   from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#8  0x00007ffff5e1234a in <rustc_parse::parser::Parser>::expect_one_of () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#9  0x00007ffff5d78a4c in <rustc_parse::parser::Parser>::check_mistyped_turbofish_with_multiple_type_params () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#10 0x00007ffff5e04a0d in <rustc_parse::parser::Parser>::parse_full_stmt () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#11 0x00007ffff5e03a5b in <rustc_parse::parser::Parser>::parse_block_tail () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#12 0x00007ffff5e03884 in <rustc_parse::parser::Parser>::parse_block_common () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#13 0x00007ffff5da93b1 in <rustc_parse::parser::Parser>::parse_expr_block () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#14 0x00007ffff5dfd1bc in <rustc_parse::parser::Parser>::parse_const_arg () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#15 0x00007ffff5dbd2b1 in <rustc_parse::parser::Parser>::parse_const_param () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#16 0x00007ffff5dbebb3 in <rustc_parse::parser::Parser>::parse_generic_params::{closure#0} () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#17 0x00007ffff5dbda5a in <rustc_parse::parser::Parser>::parse_generic_params () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#18 0x00007ffff5e11232 in <rustc_parse::parser::Parser>::parse_late_bound_lifetime_defs () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#19 0x00007ffff5dc1bd5 in <rustc_parse::parser::Parser>::parse_ty_where_predicate () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#20 0x00007ffff5dc0d2d in <rustc_parse::parser::Parser>::parse_where_clause_common () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#21 0x00007ffff5ddd17b in <rustc_parse::parser::Parser>::parse_fn () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#22 0x00007ffff5dc54c1 in <rustc_parse::parser::Parser>::parse_item_kind () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#23 0x00007ffff5dc3e2e in <rustc_parse::parser::Parser>::parse_item_common () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#24 0x00007ffff5dc36b6 in <rustc_parse::parser::Parser>::parse_item_ () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#25 0x00007ffff5dc2ed2 in <rustc_parse::parser::Parser>::parse_mod () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#26 0x00007ffff5e57724 in rustc_parse::parse_crate_from_file () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#27 0x00007ffff2fb7c56 in <rustc_session::session::Session>::time::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::diagnostic::Diag>, rustc_interface::passes::parse::{closure#0}> ()
   from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#28 0x00007ffff2f73900 in rustc_interface::passes::parse () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#29 0x00007ffff30058ba in <rustc_interface::queries::Queries>::parse () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#30 0x00007ffff2cd90d2 in <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>> () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#31 0x00007ffff2d71f48 in <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> ()
   from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#32 0x00007ffff2d3f4ac in rustc_span::create_session_globals_then::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}> () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#33 0x00007ffff2d5e742 in _RINvNtNtCs69hc0yIuJnT_3std10sys_common9backtrace28___rust_begin_short_backtraceNCNCINvNtCs16xyWfNkGXi_15rustc_interface4util26run_in_thread_with_globalsNCINvB1m_31run_in_thread_pool_with_globalsNCINvNtB1o_9interface12run_compilerINtNtCs3F8Jha18Tk_4core6result6ResultuNtCs2Po303rOvog_10rustc_span15ErrorGuaranteedENCNvCsibkQhQqy7rQ_17rustc_driver_impl12run_compiler0Es_0B3F_E0B3F_E00B3F_EB55_.llvm.10632995656702153844 () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#34 0x00007ffff2d7b70a in <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#2} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} () from /checkout/obj/install/bin/../lib/librustc_driver-a38047290982a239.so
#35 0x00007ffff1f494d4 in std::sys::pal::unix::thread::Thread::new::thread_start () from /checkout/obj/install/bin/../lib/libstd-0062bd36a972ae2a.so
#36 0x00007ffff1d16ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#37 0x00007ffff1da8850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

@compiler-errors
Copy link
Member

Minimal:

fn foo() {
    let x = Tr<A, A:>;
}

fn main() {}

@compiler-errors compiler-errors self-assigned this May 8, 2024
@compiler-errors compiler-errors removed the E-needs-stack Call for participation: This issue needs a stacktrace. label May 8, 2024
@bors bors closed this as completed in e7bb090 May 11, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 11, 2024
Rollup merge of rust-lang#124930 - compiler-errors:consume-arg, r=petrochenkov

Make sure we consume a generic arg when checking mistyped turbofish

When recovering un-turbofish-ed args in expr position (e.g. `let x = a<T, U>();` in `check_mistyped_turbofish_with_multiple_type_params`, we used `parse_seq_to_before_end` to parse the fake generic args; however, it used `parse_generic_arg` which *optionally* parses a generic arg. If it doesn't end up parsing an arg, it returns `Ok(None)` and consumes no tokens. If we don't find a delimiter after this (`,`), we try parsing *another* element. In this case, we just infinitely loop looking for a subsequent element.

We can fix this by making sure that we either parse a generic arg or error in `parse_seq_to_before_end`'s callback.

Fixes rust-lang#124897
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 11, 2024
@jieyouxu jieyouxu added A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 11, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants