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

thread '<unnamed>' panicked at 'assertion failed: p.at(T![\'{\'])', crates/parser/src/grammar/items.rs:312:5 #10083

Closed
bjorn3 opened this issue Aug 30, 2021 · 3 comments
Labels
A-parser parser issues Broken Window Bugs / technical debt to be addressed immediately S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@bjorn3
Copy link
Member

bjorn3 commented Aug 30, 2021

I got the second panic while working on compiler/rustc_hir_pretty/src/lib.rs. I didn't notice the first panic before, so I don't know exactly where it happened.

[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
Panic context:
> 
version: d15f646ff 2021-08-30 stable
request: rust-analyzer/inlayHints InlayHintsParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/bjorn/Projects/rust/compiler/rustc_codegen_cranelift/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
}

thread '<unnamed>' panicked at 'assertion failed: p.at(T![\'{\'])', crates/parser/src/grammar/items.rs:312:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:50:5
   3: parser::grammar::items::extern_item_list
   4: parser::grammar::items::maybe_item
   5: parser::grammar::items::item_or_macro
   6: parser::grammar::items::mod_contents
   7: parser::grammar::root
   8: syntax::parsing::parse_text
   9: syntax::<impl syntax::ast::generated::nodes::SourceFile>::parse
  10: <base_db::ParseQuery as salsa::plumbing::QueryFunction>::execute
  11: salsa::runtime::Runtime::execute_query_implementation
  12: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  13: salsa::derived::slot::Slot<Q,MP>::read
  14: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  15: <DB as base_db::SourceDatabase>::parse
  16: hir::semantics::SemanticsImpl::parse
  17: ide::inlay_hints::inlay_hints
  18: std::panicking::try
  19: rust_analyzer::handlers::handle_inlay_hints
  20: rust_analyzer::dispatch::RequestDispatcher::on::{{closure}}::{{closure}}
  21: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: d15f646ff 2021-08-30 stable
request: rust-analyzer/inlayHints InlayHintsParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/bjorn/Projects/rust/compiler/rustc_codegen_cranelift/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
}

thread '<unnamed>' panicked at 'assertion failed: p.at(T![\'{\'])', crates/parser/src/grammar/items.rs:312:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:50:5
   3: parser::grammar::items::extern_item_list
   4: parser::grammar::items::maybe_item
   5: parser::grammar::items::item_or_macro
   6: parser::grammar::items::mod_contents
   7: parser::grammar::root
   8: syntax::parsing::parse_text
   9: syntax::<impl syntax::ast::generated::nodes::SourceFile>::parse
  10: <base_db::ParseQuery as salsa::plumbing::QueryFunction>::execute
  11: salsa::runtime::Runtime::execute_query_implementation
  12: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  13: salsa::derived::slot::Slot<Q,MP>::read
  14: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  15: <DB as base_db::SourceDatabase>::parse
  16: hir::semantics::SemanticsImpl::parse
  17: ide::inlay_hints::inlay_hints
  18: std::panicking::try
  19: rust_analyzer::handlers::handle_inlay_hints
  20: rust_analyzer::dispatch::RequestDispatcher::on::{{closure}}::{{closure}}
  21: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@jonas-schievink jonas-schievink added A-parser parser issues Broken Window Bugs / technical debt to be addressed immediately labels Aug 30, 2021
@jonas-schievink
Copy link
Contributor

Can't reproduce this on cbae596 + rust-lang/rust@13edc17, so this might have been introduced by local changes.

The failing assertion is

https://github.com/rust-analyzer/rust-analyzer/blob/cbae5969417eba9c9fbaee0337c8f57e566fd286/crates/parser/src/grammar/items.rs#L311-L312

which is a bit weird, since there's no extern blocks in that file.

@jonas-schievink jonas-schievink added the S-unactionable Issue requires feedback, design decisions or is blocked on other work label Aug 30, 2021
@matklad
Copy link
Member

matklad commented Aug 30, 2021

wow, seems like a genuine bug in the parser, haven't seen one in a while, taking a look.

@matklad
Copy link
Member

matklad commented Aug 30, 2021

Minimal repro:

unsafe extern "C" extern ""

for the parser, it's usually easy to reverse-engineer a repro by tracing form failed assert backwards, which gives this snippet which doesn't check the precondition:

https://github.com/matklad/rust-analyzer/blob/a833fba98aaa728b16d23db3da04c624601b0751/crates/parser/src/grammar/items.rs#L215-L220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser parser issues Broken Window Bugs / technical debt to be addressed immediately S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

No branches or pull requests

3 participants