rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

thread 'Worker' panicked

Open pfwang80s opened this issue 11 months ago • 11 comments

version: 0.3.2228

2024-12-28T23:08:12.029781324+08:00 ERROR Position LineCol { line: 55, col: 13 } column exceeds line length 11, clamping it 2024-12-28T23:08:12.029840077+08:00 ERROR Position LineCol { line: 55, col: 13 } column exceeds line length 11, clamping it 2024-12-28T23:09:11.04839502+08:00 ERROR Position LineCol { line: 89, col: 18 } column exceeds line length 1, clamping it 2024-12-28T23:09:11.048452108+08:00 ERROR Position LineCol { line: 89, col: 18 } column exceeds line length 1, clamping it 2024-12-28T23:09:11.048460884+08:00 ERROR Position LineCol { line: 120, col: 18 } column exceeds line length 1, clamping it 2024-12-28T23:09:11.048468112+08:00 ERROR Position LineCol { line: 120, col: 18 } column exceeds line length 1, clamping it 2024-12-28T23:09:11.048475134+08:00 ERROR Position LineCol { line: 131, col: 24 } column exceeds line length 1, clamping it 2024-12-28T23:09:11.048482934+08:00 ERROR Position LineCol { line: 131, col: 24 } column exceeds line length 1, clamping it 2024-12-28T23:09:11.048491434+08:00 ERROR Position LineCol { line: 141, col: 24 } column exceeds line length 2, clamping it 2024-12-28T23:09:11.048498255+08:00 ERROR Position LineCol { line: 141, col: 24 } column exceeds line length 2, clamping it 2024-12-28T23:09:29.769465964+08:00 ERROR Position LineCol { line: 120, col: 18 } column exceeds line length 1, clamping it 2024-12-28T23:09:29.769498334+08:00 ERROR Position LineCol { line: 120, col: 18 } column exceeds line length 1, clamping it 2024-12-28T23:09:29.769502598+08:00 ERROR Position LineCol { line: 131, col: 24 } column exceeds line length 1, clamping it 2024-12-28T23:09:29.769505802+08:00 ERROR Position LineCol { line: 131, col: 24 } column exceeds line length 1, clamping it 2024-12-28T23:09:29.769509167+08:00 ERROR Position LineCol { line: 141, col: 24 } column exceeds line length 2, clamping it 2024-12-28T23:09:29.769512141+08:00 ERROR Position LineCol { line: 141, col: 24 } column exceeds line length 2, clamping it 2024-12-28T23:11:08.748416828+08:00 ERROR Position LineCol { line: 140, col: 19 } column exceeds line length 10, clamping it 2024-12-28T23:11:08.748492679+08:00 ERROR Position LineCol { line: 140, col: 19 } column exceeds line length 10, clamping it 2024-12-28T23:14:43.440354304+08:00 ERROR Position LineCol { line: 934, col: 30 } column exceeds line length 14, clamping it 2024-12-28T23:14:43.440404285+08:00 ERROR Position LineCol { line: 934, col: 30 } column exceeds line length 14, clamping it 2024-12-28T23:14:50.925405007+08:00 ERROR Position LineCol { line: 934, col: 30 } column exceeds line length 14, clamping it 2024-12-28T23:14:50.925445526+08:00 ERROR Position LineCol { line: 934, col: 30 } column exceeds line length 14, clamping it Panic context:

version: 0.3.2228-standalone request: textDocument/diagnostic DocumentDiagnosticParams { text_document: TextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/user1/txnkv/participant/src/page.rs", query: None, fragment: None, }, }, identifier: None, previous_result_id: Some( "rust-analyzer", ), work_done_progress_params: WorkDoneProgressParams { work_done_token: None, }, partial_result_params: PartialResultParams { partial_result_token: None, }, }

thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chalk-ir-0.98.0/src/lib.rs:2238:9: assertion left == right failed left: 2 right: 1 stack backtrace: 0: rust_begin_unwind 1: core::panicking::panic_fmt 2: core::panicking::assert_failed_inner 3: core::panicking::assert_failed 4: chalk_ir::Binders<T>::substitute 5: hir_ty::mir::ProjectionElem<V,T>::projected_ty 6: hir_ty::mir::borrowck::moved_out_of_ref::{{closure}} 7: hir_ty::mir::borrowck::borrowck_query::{{closure}} 8: hir_ty::mir::borrowck::borrowck_query 9: ra_salsa::derived_lru::slot::Slot<Q,MP>::execute 10: ra_salsa::derived_lru::slot::Slot<Q,MP>::read 11: <ra_salsa::derived_lru::DerivedStorage<Q,MP> as ra_salsa::plumbing::QueryStorageOps<Q>>::fetch 12: <DB as hir_ty::db::HirDatabase>::borrowck 13: hir::DefWithBody::diagnostics 14: hir::Module::diagnostics 15: ide_diagnostics::semantic_diagnostics 16: ide_diagnostics::full_diagnostics 17: ra_salsa::Cancelled::catch 18: ide::Analysis::full_diagnostics 19: rust_analyzer::handlers::request::handle_document_diagnostics 20: core::ops::function::FnOnce::call_once{{vtable.shim}} note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace. [Error - 11:15:44 PM] Request textDocument/diagnostic failed. Message: request handler panicked: assertion left == right failed left: 2 right: 1 Code: -32603 [Error - 11:15:44 PM] Document pull failed for text document file:///home/user1/txnkv/participant/src/page.rs Message: request handler panicked: assertion left == right failed left: 2 right: 1 Code: -32603 Panic context:

version: 0.3.2228-standalone request: textDocument/codeAction CodeActionParams { text_document: TextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/user1/txnkv/participant/src/page.rs", query: None, fragment: None, }, }, range: Range { start: Position { line: 930, character: 41, }, end: Position { line: 930, character: 41, }, }, context: CodeActionContext { diagnostics: [], only: None, trigger_kind: Some( Automatic, ), }, work_done_progress_params: WorkDoneProgressParams { work_done_token: None, }, partial_result_params: PartialResultParams { partial_result_token: None, }, }

thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chalk-ir-0.98.0/src/lib.rs:2238:9: assertion left == right failed left: 2 right: 1 stack backtrace: 0: rust_begin_unwind 1: core::panicking::panic_fmt 2: core::panicking::assert_failed_inner 3: core::panicking::assert_failed 4: chalk_ir::Binders<T>::substitute 5: hir_ty::mir::ProjectionElem<V,T>::projected_ty 6: hir_ty::mir::borrowck::moved_out_of_ref::{{closure}} 7: hir_ty::mir::borrowck::borrowck_query::{{closure}} 8: hir_ty::mir::borrowck::borrowck_query 9: ra_salsa::derived_lru::slot::Slot<Q,MP>::execute 10: ra_salsa::derived_lru::slot::Slot<Q,MP>::read 11: <ra_salsa::derived_lru::DerivedStorage<Q,MP> as ra_salsa::plumbing::QueryStorageOps<Q>>::fetch 12: <DB as hir_ty::db::HirDatabase>::borrowck 13: hir::DefWithBody::diagnostics 14: hir::Module::diagnostics 15: ide_diagnostics::semantic_diagnostics 16: ide_diagnostics::full_diagnostics 17: ra_salsa::Cancelled::catch 18: rust_analyzer::handlers::request::handle_code_action 19: core::ops::function::FnOnce::call_once{{vtable.shim}} note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace. Panic context:

version: 0.3.2228-standalone request: textDocument/codeAction CodeActionParams { text_document: TextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/user1/txnkv/participant/src/page.rs", query: None, fragment: None, }, }, range: Range { start: Position { line: 930, character: 41, }, end: Position { line: 930, character: 41, }, }, context: CodeActionContext { diagnostics: [ Diagnostic { range: Range { start: Position { line: 930, character: 41, }, end: Position { line: 930, character: 41, }, }, severity: Some( Error, ), code: Some( String( "Click for full compiler diagnostic", ), ), code_description: Some( CodeDescription { href: Url { scheme: "rust-analyzer-diagnostics-view", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/diagnostic%20message%20%5B0%5D", query: Some( "0", ), fragment: Some( "file%3A%2F%2F%2Fhome%2Fuser1%2Ftxnkv%2Fparticipant%2Fsrc%2Fpage.rs", ), }, }, ), source: Some( "rustc", ), message: "expected ;, found sibling", related_information: Some( [ DiagnosticRelatedInformation { location: Location { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/user1/txnkv/participant/src/page.rs", query: None, fragment: None, }, range: Range { start: Position { line: 931, character: 8, }, end: Position { line: 931, character: 15, }, }, }, message: "unexpected token", }, DiagnosticRelatedInformation { location: Location { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/user1/txnkv/participant/src/page.rs", query: None, fragment: None, }, range: Range { start: Position { line: 930, character: 41, }, end: Position { line: 930, character: 41, }, }, }, message: "add ; here: ;", }, ], ), tags: None, data: Some( Object { "rendered": String("\u{1b}[0m\u{1b}[1m\u{1b}[38;5;9merror\u{1b}[0m\u{1b}[0m\u{1b}[1m: expected ;, found sibling\u{1b}[0m\n\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m--> \u{1b}[0m\u{1b}[0mparticipant/src/page.rs:931:42\u{1b}[0m\n\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m|\u{1b}[0m\n\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m931\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m|\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m let sibling_frame = sibling.frame\u{1b}[0m\n\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m|\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;9m^\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;9mhelp: add ; here\u{1b}[0m\n\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m932\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m|\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m sibling.set_last_seq(xlog.push(\u{1b}[0m\n\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m|\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12m-------\u{1b}[0m\u{1b}[0m \u{1b}[0m\u{1b}[0m\u{1b}[1m\u{1b}[38;5;12munexpected token\u{1b}[0m\n\n"), }, ), }, Diagnostic { range: Range { start: Position { line: 930, character: 41, }, end: Position { line: 930, character: 41, }, }, severity: Some( Hint, ), code: None, code_description: None, source: Some( "rustc", ), message: "add ; here: ;", related_information: Some( [ DiagnosticRelatedInformation { location: Location { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/user1/txnkv/participant/src/page.rs", query: None, fragment: None, }, range: Range { start: Position { line: 930, character: 41, }, end: Position { line: 930, character: 41, }, }, }, message: "original diagnostic", }, ], ), tags: None, data: None, }, ], only: None, trigger_kind: Some( Automatic, ), }, work_done_progress_params: WorkDoneProgressParams { work_done_token: None, }, partial_result_params: PartialResultParams { partial_result_token: None, }, }

thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chalk-ir-0.98.0/src/lib.rs:2238:9: assertion left == right failed left: 2 right: 1 stack backtrace: 0: rust_begin_unwind 1: core::panicking::panic_fmt 2: core::panicking::assert_failed_inner 3: core::panicking::assert_failed 4: chalk_ir::Binders<T>::substitute 5: hir_ty::mir::ProjectionElem<V,T>::projected_ty 6: hir_ty::mir::borrowck::moved_out_of_ref::{{closure}} 7: hir_ty::mir::borrowck::borrowck_query::{{closure}} 8: hir_ty::mir::borrowck::borrowck_query 9: ra_salsa::derived_lru::slot::Slot<Q,MP>::execute 10: ra_salsa::derived_lru::slot::Slot<Q,MP>::read 11: <ra_salsa::derived_lru::DerivedStorage<Q,MP> as ra_salsa::plumbing::QueryStorageOps<Q>>::fetch 12: <DB as hir_ty::db::HirDatabase>::borrowck 13: hir::DefWithBody::diagnostics 14: hir::Module::diagnostics 15: ide_diagnostics::semantic_diagnostics 16: ide_diagnostics::full_diagnostics 17: ra_salsa::Cancelled::catch 18: rust_analyzer::handlers::request::handle_code_action 19: core::ops::function::FnOnce::call_once{{vtable.shim}} note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

pfwang80s avatar Dec 28 '24 15:12 pfwang80s

That will need a reproducer for us to be actionable

Veykril avatar Dec 28 '24 15:12 Veykril

Not sure how to get reproducer either, but I'm also getting this error. Will report back if I can figure out how to reproduce it.

I noticed that the error squiggles aren't updated on save because (I think) cargo check isn't being run even though the check-on-save setting is set to true. This behavior seems related to this bug.

tylers-epilog avatar Jan 06 '25 23:01 tylers-epilog

I noticed that the error squiggles aren't updated on save because (I think) cargo check isn't being run even though the check-on-save setting is set to true. This behavior seems related to this bug.

This isn't related, this is #18854, and it already has a fix: https://github.com/rust-lang/rust-analyzer/pull/18858.

ChayimFriedman2 avatar Jan 06 '25 23:01 ChayimFriedman2

Well that's a relief! Thanks for the heads up! Looking forward to that fix being pushed.

tylers-epilog avatar Jan 06 '25 23:01 tylers-epilog

For anyone else coming here because they saw the error in vscode when auto completion was failing, after doing a git bissect on this project between when it worked last for me via 2024-12-16 and when it stopped working via 2024-12-23, I got 02d47f3a81aedc4effecc58f5e2b1537fe2a8ac6 as the commit which introduced this behavior for me.

I do see #18834 and #18888 and #18889 attempted to resolve some of the "regressions" from that commit (which was introduced via #18723).

I did try the latest release of 2025-01-13 but still saw the failing case. I also tried master which is 903bc8133cc788a07bde3cd6ac8a045e8a78f609 as of now, but still no dice. I was hoping if I might be able to "just" revert the commit in question atop master, but the conflict resolution is above my skills with rust and familiarity with this codebase. I have been trying to get a minimal reproducible example but haven't been able to be lucky with what I extract from my proprietary codebase to reproduce this.

Hopefully this helps anyone else who might be getting hit by this.

hak8or avatar Jan 16 '25 23:01 hak8or

@hak8or Do you have a reproduction?

ChayimFriedman2 avatar Jan 17 '25 13:01 ChayimFriedman2

@hak8or Do you have a reproduction?

I have continued to attempt to get a minimal reproducible example since I posted a few days, but have sadly failed in my attempts. I cannot share the codebase I am seeing this in because it's proprietary. I will continue to attempt to check new releases if I see any changes, and making a small reproducible.

Would you want me to shift this to a new issue, or keep it here as is?

hak8or avatar Jan 18 '25 15:01 hak8or

When you'll have a reproduction, I think a new issue should be preferred, since this one doesn't have a reproduction.

ChayimFriedman2 avatar Jan 18 '25 16:01 ChayimFriedman2

Hi! Just got similar issue with open repo I'm working on, hopefully it can help you to reproduce the issue. The repo: https://github.com/vanviethieuanh/iron-spider/commit/4dcb337e4a7840d7ffb852793bd467cdd16f2161 And in LSP log:

[ERROR][2025-06-10 13:32:14] ...p/_transport.lua:36	"rpc"	"rust-analyzer"	"stderr"	"2025-06-10T13:32:14.400617862+07:00 ERROR Position LineCol { line: 54, col: 20 } column exceeds line length 14, clamping it\n2025-06-10T13:32:14.400654238+07:00 ERROR Position LineCol { line: 54, col: 20 } column exceeds line length 14, clamping it\n2025-06-10T13:32:14.400659395+07:00 ERROR Position LineCol { line: 54, col: 21 } column exceeds line length 14, clamping it\n2025-06-10T13:32:14.400662604+07:00 ERROR Position LineCol { line: 54, col: 21 } column exceeds line length 14, clamping it\n"

Currently LSP Format doing nothing. Anyway to workaround?

vanviethieuanh avatar Jun 10 '25 07:06 vanviethieuanh

Any updates for this?

Yunuuuu avatar Jun 11 '25 12:06 Yunuuuu

That will need a reproducer for us to be actionable

Veykril avatar Jun 11 '25 13:06 Veykril

I think i have an idea what is happening here. Some editor extensions inline "phantom" code in the editor, mostly AI assistants. This is different from inline hints, as extensions expect this code to have valid syntax highlighting, so it gets sent to the LSP.

https://github.com/rust-lang/rust-analyzer/blob/0ac65592a833bf40238831dd10e15283d63c46d5/crates/rust-analyzer/src/lsp/from_proto.rs#L41-L45

Here line_col is a struct containing indexes as reported by the editor, including extension-generated code. col, however, (from my understanding) references only the "real" code in the syntax tree.

I can semi-consistently reproduce this by installing a VSCode AI assistant extension (specifically Supermaven) and typing arbitrary code then waiting for a completion. I say semi-consistently because there is a race: if all LSP-related tasks are done before an extension comes up with code to suggest (which is common for heavier AI models), this bug does not occur.

I'm not sure if this is unintended behavior in rust-analyzer or the extension. As a quick fix, try turning off any extensions doing inline code generation.

hazyfossa avatar Jul 06 '25 19:07 hazyfossa

That is unrelated, that column exceed error there is due to a r-a bug itself, but thats just an error log, not a panic.

Veykril avatar Jul 06 '25 19:07 Veykril

I can also report having the same issue with the latest version of RA (released on 2025-08-04, although it's been happening for much longer than this).

2025-08-11T16:28:49.626467-04:00 ERROR Position LineCol { line: 1144, col: 71 } column exceeds line length 38, clamping it
2025-08-11T16:28:49.626468-04:00 ERROR Position LineCol { line: 1160, col: 82 } column exceeds line length 35, clamping it
2025-08-11T16:28:49.626469-04:00 ERROR Position LineCol { line: 1160, col: 82 } column exceeds line length 35, clamping it
2025-08-11T16:28:49.626768-04:00 ERROR Position LineCol { line: 1099, col: 56 } column exceeds line length 27, clamping it
2025-08-11T16:28:49.626782-04:00 ERROR Position LineCol { line: 1099, col: 65 } column exceeds line length 27, clamping it
2025-08-11T16:28:49.626783-04:00 ERROR Position LineCol { line: 1144, col: 62 } column exceeds line length 38, clamping it
2025-08-11T16:28:49.626784-04:00 ERROR Position LineCol { line: 1144, col: 71 } column exceeds line length 38, clamping it
2025-08-11T16:28:49.626785-04:00 ERROR Position LineCol { line: 1160, col: 82 } column exceeds line length 35, clamping it
2025-08-11T16:28:49.626786-04:00 ERROR Position LineCol { line: 1160, col: 82 } column exceeds line length 35, clamping it
2025-08-11T16:28:49.62821-04:00 ERROR Position LineCol { line: 1099, col: 56 } column exceeds line length 27, clamping it
2025-08-11T16:28:49.628221-04:00 ERROR Position LineCol { line: 1099, col: 65 } column exceeds line length 27, clamping it
2025-08-11T16:28:49.628222-04:00 ERROR Position LineCol { line: 1144, col: 62 } column exceeds line length 38, clamping it
2025-08-11T16:28:49.628223-04:00 ERROR Position LineCol { line: 1144, col: 71 } column exceeds line length 38, clamping it
2025-08-11T16:28:49.628224-04:00 ERROR Position LineCol { line: 1160, col: 82 } column exceeds line length 35, clamping it
2025-08-11T16:28:49.628225-04:00 ERROR Position LineCol { line: 1160, col: 82 } column exceeds line length 35, clamping it
2025-08-11T16:28:49.80613-04:00 ERROR Position LineCol { line: 1099, col: 56 } column exceeds line length 27, clamping it
2025-08-11T16:28:49.806143-04:00 ERROR Position LineCol { line: 1099, col: 65 } column exceeds line length 27, clamping it
2025-08-11T16:28:49.806145-04:00 ERROR Position LineCol { line: 1144, col: 62 } column exceeds line length 38, clamping it

Unfortunately this is code for work that is not open sourced, so no repro. It might be useful to actually output the file in which RA is encountering this error, instead of somewhat vaguely emitting only the line/col numbers.

kaifastromai avatar Aug 11 '25 22:08 kaifastromai

The message was disabled in https://github.com/rust-lang/rust-analyzer/pull/20400.

lnicola avatar Aug 12 '25 05:08 lnicola