Skip to content

checklocks: allow pure atomic deferred calls - #14346

Open
tamird wants to merge 3 commits into
google:masterfrom
tamird:checklocks-deferred-atomics
Open

checklocks: allow pure atomic deferred calls#14346
tamird wants to merge 3 commits into
google:masterfrom
tamird:checklocks-deferred-atomics

Conversation

@tamird

@tamird tamird commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

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

tamird added 3 commits August 22, 2026 01:44
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
@tamird

tamird commented Aug 22, 2026

Copy link
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant