fix: invariants of the ST.Ref implementation - #14775
Open
hargoniX wants to merge 2 commits into
Open
Conversation
hargoniX
force-pushed
the
hbv/fix_stref
branch
from
August 13, 2026 12:02
64d4004 to
270f2c7
Compare
Member
Author
|
!bench |
|
Benchmark results for 270f2c7 against 5847d9b are in. No significant results found. @hargoniX
New metrics (19✅, 43🟥, 1)
Small changes (3✅, 1🟥)
|
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
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.
This PR fixes the remaining issues with
ST.Ref. We now enforce thatST.Refacts truly like a spinlock by introducing two changes:ST.Ref.setis now justdiscard <| ST.Ref.swapand fulfills no special purpose for closing the critical section opened byST.Ref.takeanymoreunsafefunction calledST.Ref.putwhich may only be called after a critical section has been opened using theunsafeST.Ref.take. We then implementmodifyand friends using these operations.In addition, enforcing that
ST.Refis a proper spinlock allows us to remove a few branches around previous races withST.Ref.set.The PR is accompanied by a formalization on the stref-veil repo: TODO