Skip to content

[ty] Temporary fix for PropagatedPanic crashes#25463

Closed
MichaReiser wants to merge 1 commit into
mainfrom
micha/ty-cancellation-synthetic-write-workaround
Closed

[ty] Temporary fix for PropagatedPanic crashes#25463
MichaReiser wants to merge 1 commit into
mainfrom
micha/ty-cancellation-synthetic-write-workaround

Conversation

@MichaReiser

@MichaReiser MichaReiser commented May 29, 2026

Copy link
Copy Markdown
Member

Summary

This is a workaround for #3339 to give me some more time to implement a proper fix in Salsa.

The issue is that the fixpoint computation incorrectly assumes that the only reason a fixpoint query can panic is a bug in the implementation. In which case it doesn't make sense to re-run the query within the same revision because it is only going to panic again (we don't re-run the query in the same revision because there are stale values from the previous revision that Salsa might end up picking up as fresh values). However, that's not the case. The query can also panic if the execution gets cancelled because another thread tries to write (tries to acquire a mut db).

This PR works around this limitation by changing all code paths in ty where we acquire a &mut Db without bumping the revision so that we bump the revision instead. This has the downside that Salsa has to do a little more work to verify that it's okay to reuse all cached queries (because nothing changed). But this seems clearly better than just crashing (and many users seem to be running into this).

@MichaReiser MichaReiser added the ty Multi-file analysis & type inference label May 29, 2026
@MichaReiser MichaReiser changed the title [ty] Work around cancellation without a Salsa revision [ty] Temporary fix for PropagatedPanic crashes May 29, 2026
}

#[cfg(test)]
pub(crate) mod cancellation_tests {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO, remove. I only needed these to verify the issue

/// WARNING: Triggers a new revision, canceling other database handles. This can lead to deadlock.
pub fn system_mut(&mut self) -> &mut dyn System {
self.trigger_cancellation();
self.synthetic_write(Durability::LOW);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add todo comments

@astral-sh-bot

astral-sh-bot Bot commented May 29, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 91.94%. The percentage of expected errors that received a diagnostic held steady at 87.09%. The number of fully passing files held steady at 92/134.

@astral-sh-bot

astral-sh-bot Bot commented May 29, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented May 29, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@MichaReiser

Copy link
Copy Markdown
Member Author

This made me realise that the most simplistic fix in salsa isn't much harder than always bumping the revision when a fixpoint query was cancelled. Closing, given that it shouldn't take me much time to land this fix upstream (see salsa-rs/salsa#1100),

@MichaReiser MichaReiser closed this Jun 1, 2026
@MichaReiser MichaReiser mentioned this pull request Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant