Repository navigation
Prevents repeated panics from 14 poisoned locks after a caught panic - #3486
Merged
HakanSeven12 merged 2 commits intoNov 23, 2026
Merged
Conversation
A Mutex that was locked at a panic stays poisoned, and .lock().unwrap() then panics at each later lock. The 14 sites in LENGTHEN, the HTTP bridge, the schema cache and the extraction catalog now recover the data with .unwrap_or_else(|e| e.into_inner()), as the other locks of the code base do. Co-Authored-By: Claude
Co-Authored-By: Claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change summary
A
Mutexthat was locked when a thread panicked stays poisoned..lock().unwrap()then panics at each later lock, so one caught panic becomes a panic at each later use. Most of the code base already recovers the data with.lock().unwrap_or_else(|e| e.into_inner())(#3148 did this for the font locks). 14 sites in code for each platform did not:src/modules/draw/modify/lengthen.rssrc/app/control/http_bridge.rssrc/schema_validation.rssrc/app/extraction_catalog.rsThis change makes them use the same recovery.
One of them has a path to a poisoned lock in the code today.
validate_shapecompiles a schema with.expect("application-owned schema must compile")while it holds the cache lock. If one schema does not compile, that panic poisons the cache, and each later validation of each other schema panics with "schema cache poisoned". The map is not changed before the panic, so its data stays good.For the other three locks, the code that holds the lock only reads or writes plain values, so a panic there is not probable. The change makes them follow the rule of the code base.
What specifically changed
Two commits: the fix, then its tests.
.lock().unwrap()and.lock().expect(..)become.lock().unwrap_or_else(|e| e.into_inner()). No other change.src/modules/draw/modify/lengthen.rs: a test poisons the lock of the defaults and then goes through each of the 9 sites. An existing test reads the lock with the same recovery now, because the tests run in parallel.src/schema_validation.rs: a schema that does not compile panics; a validation with a good schema after that gives its usual results.src/app/control/http_bridge.rs:harvestrecords the document id through a poisoned cache.Why
Testing
On main
120199c0b..unwrap()put back in the production code of the three files, all 3 new tests fail..unwrap()put back at one site at a time, the LENGTHEN test fails for each of the 9 sites.cargo test --workspace --locked --no-fail-fast,cargo check --workspace --all-targets, clippy, the wasm32 check, rustfmt on the changed files, the golden file): 7,735 passed and 0 failed before; 7,737 passed and 1 failed after. The 3 new tests pass. The one failure ispicklocked_off_makes_locked_layer_objects_unselectable, which is not stable on main (Test picklocked_off_makes_locked_layer_objects_unselectable fails at random when tests run in parallel #3468; Prevents random failures of the PICKLOCKED test when tests run in parallel #3485 repairs it) and is not from this change. Warnings, the wasm32 check, clippy, rustfmt and the golden file are the same.cargo mutantson the diff: 13 mutants, 6 caught, 3 timeouts, 2 not viable, 2 missed. The timeouts are in the HTTP bridge, where a bridge test waits for an answer that the mutant never gives. The 2 missed mutants replace the result ofleaked(extraction_catalog.rs); the run used only the tests of the four changed modules, and the tests ofannotation_datacatch that mutant (2 of them fail with it by hand).Not covered
src/input/: SpaceMouse and trackpad, 17 sites). Each part compiles on one platform only. A separate change.src/app/control/mod.rs,src/scene/text/web_font.rs, 8 sites). The web build stops on a panic, so a poisoned lock cannot occur there.validate_shapestill panics for that schema. Only the later validations are repaired.Impact to Contributors
For a lock whose data stays valid after a panic, use
.lock().unwrap_or_else(|e| e.into_inner()), not.lock().unwrap().Co-Authored-By: Claude