checklocks: allow pure atomic deferred calls - #14346
Open
tamird wants to merge 3 commits into
Open
Conversation
Recognize atomicbitops Racy methods as non-atomic operations. Permit mixed-mode RacyLoad only when all guards are held, and require atomic writes with all guards held exclusively. Distinguish shared-lock reads from lock-free atomic reads so an RLock cannot authorize writes. Check atomic uses of annotated globals at the consuming instruction instead of discarding that instruction. Keep unannotated-global behavior unchanged, preserve function and closure ignores, and distinguish writes to a global from stores of its address. Resolve generic instantiations to their original declarations before classifying atomic operations. This recognizes atomic.Pointer methods without bypassing package or mixed-access checks for generic calls. Assisted-by: Codex
The Go parser places standalone variable documentation on GenDecl, while checklocks only reads ValueSpec.Doc. As a result, standalone global lock and atomic annotations are silently ignored. A multi-name declaration also exports facts only for its first variable. Keep the enclosing declaration when collecting global facts. Read its documentation for standalone declarations and retain per-entry documentation for var blocks. Export fresh facts for each named variable, skipping blank identifiers. Extend the existing local and cross-package fixtures to cover these forms, atomic direct writes, and var-block comment boundaries. Assisted-by: Codex
Atomic-use checking rejects valid deferred operations, including the global logger's restoration with atomic.Pointer.Store once its declaration annotation is active. Classify pure atomic defers using the ordinary atomic-call rules, preserving generic method support and the existing explicit-force bypass. Guarded defers remain rejected: checking their locks when registered would not establish ownership when executed. Extend the existing atomic fixtures to cover deferred consumers and the conservative boundaries for mixed accesses, Racy methods, and goroutines. Assisted-by: Codex
Contributor
Author
|
r? @EtiennePerot Could you review pure deferred atomic calls and the conservative boundary for guarded defers? Focused local Bazel checks passed. No upstream build/test result is reported yet. This comparison currently includes the prerequisites linked in the description. The reviewer-assignment check failed with HTTP 422 because at least one selected reviewer is not an eligible repository collaborator. The job does not identify which account. This is an assignment-automation failure, not a build/test failure; the review request above remains in place. Assisted-by: Codex |
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.
Depends on #14281 and #14282. The change specific to this proposal is 6d996eb. The current comparison against master also includes prerequisite commits; those prerequisites must land and be removed from this branch before submission.
Atomic-use checking rejects valid deferred operations, including the global logger's restoration with atomic.Pointer.Store once its declaration annotation is active.
Classify pure atomic defers using the ordinary atomic-call rules, preserving generic method support and the existing explicit-force bypass. Guarded defers remain rejected: checking their locks when registered would not establish ownership when executed.
Extend the existing atomic fixtures to cover deferred consumers and the conservative boundaries for mixed accesses, Racy methods, and goroutines.
Assisted-by: Codex