checklocks: enforce logging output ownership - #14347
Open
tamird wants to merge 4 commits into
Open
Conversation
Contributor
Author
|
r? @EtiennePerot Could you review logging ownership and the pure deferred-atomic integration? Focused local Bazel checks passed. Upstream checks have not reported yet. This comparison currently includes the prerequisites linked in the description. Assisted-by: Codex |
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
Enforce mutex ownership of the line-writer buffer, dropped-message counter and reported-call-site map. Keep the counter's atomic fast-path reads and require atomic updates under its mutex. Retain the emitter's borrowed buffer lifetime and the map's exclusive package initialization. Require atomic access to the default logger pointer and logging level. Copy the level atomically when replacing the target, while preserving SetTarget's concurrent-use restriction. The prerequisite checker changes also support the existing deferred logger restoration. Repair the existing dropped-message assertion to compare the complete, ordered output, including the formatted count, instead of rejecting equal lines and accepting incorrect expected values. Assisted-by: Codex
tamird
force-pushed
the
checklocks-log-output
branch
from
August 22, 2026 16:19
32161d8 to
ae8ddf5
Compare
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 #14346. The change specific to this proposal is 32161d8. The current comparison against master also includes prerequisite commits; those prerequisites must land and be removed from this branch before submission.
Enforce mutex ownership of the line-writer buffer and log writer error counter. Keep atomic fast-path reads of the counter while requiring its updates to be both atomic and locked, and retain the emitter's borrowed buffer lifetime.
Require atomic access to the default logger pointer. The checker support from 6d996eb also covers its existing deferred test restoration. Keep SetTarget's concurrent-use restriction separate from pointer atomicity.
Assisted-by: Codex