You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
libsimlin: TOCTOU race in apply_project_patch_internal unit warnings check #296
In src/libsimlin/src/patch.rs, the apply_project_patch_internal function has a time-of-check to time-of-use (TOCTOU) race condition between two separate lock acquisitions on project_ref.project:
Lines 415-418: Lock to collect existing unit warnings
Lines 420-423: Lock to clone the datamodel
Between these two acquisitions, another thread could commit a different patch, making the baseline of existing warnings stale. This could cause a patch to be incorrectly accepted when it actually introduces new unit warnings.
Why It Matters
This is a correctness issue in the patch validation logic. A patch validation decision depends on the state at warning-collection time, but the actual datamodel state at patch-application time may differ due to concurrent patches. This could silently allow invalid unit warnings to be committed.
Affected Component
src/libsimlin/src/patch.rs - apply_project_patch_internal function (lines ~415-423)
Solution
Combine both lock acquisitions into a single scope:
Activity
libsimlin: add deterministic patch race regressions
libsimlin: add deterministic patch race regressions (#314)
bpowers commentedon Feb 24, 2026
Fixed in PR #289 (incremental compilation). Regression test added in PR #314.