Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
gzliudan
requested review from
AnilChinchawale,
anunay-xin,
benjamin202410,
liam-lai and
wanwiset25
October 20, 2026 23:10
gzliudan
force-pushed
the
fix-log-terminal-handler-attrs-alias
branch
from
October 22, 2026 09:06
d1ed111 to
cae1365
Compare
This was referenced Oct 24, 2026
wanwiset25
approved these changes
Oct 26, 2026
gzliudan
force-pushed
the
fix-log-terminal-handler-attrs-alias
branch
2 times, most recently
from
October 26, 2026 05:32
6552217 to
50fb6ac
Compare
anunay-xin
approved these changes
Oct 26, 2026
benjamin202410
approved these changes
Oct 26, 2026
gzliudan
force-pushed
the
fix-log-terminal-handler-attrs-alias
branch
2 times, most recently
from
October 27, 2026 10:02
217a551 to
2a69f8c
Compare
Handle discarded the error of the underlying writer, so a failing TerminalHandler silently dropped records. Propagate it to the caller instead, matching go-ethereum. Ref: ethereum#35055
…#35074 mu was a struct value, so every handler derived by WithAttrs created its own mutex over the same writer. Make it a pointer and hand the parent's mutex down, so writes through a handler family stay serialized. Ref: ethereum#35074
WithAttrs appended to h.attrs directly, so when the parent's attribute slice had spare capacity two sibling handlers wrote into the same backing array and overwrote each other's attributes. Clone it first. Ref: ethereum#35141
One case per upstream fix ported on this branch, two for the shared mutex: - a rejected write has to reach the caller (ethereum#35055); - a handler derived by WithAttrs has to share the parent's mutex, and to wait for it while the parent holds it (ethereum#35074); - two sibling handlers must not overwrite each other's attributes when the parent's attribute slice has spare capacity (ethereum#35141). Ref: ethereum#35055, ethereum#35074, ethereum#35141
gzliudan
force-pushed
the
fix-log-terminal-handler-attrs-alias
branch
from
October 27, 2026 10:23
2a69f8c to
c2a9ecf
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.
Summary
Ports the three upstream fixes that
log/handler.gonever carried. With this, the file is identical to go-ethereum'slog/handler.goat409aaefac(checked withdiffagainstgeth origin/master, zero lines).ab20d50db) --Handlediscarded the error of the underlying writer, so a failingTerminalHandlersilently dropped records. Propagate it to the caller instead, matching go-ethereum. In-tree this reaches only callers holding the handler directly:GlogHandler.Handlereturns it onwards, whilelog.Logger.Writehas no error return and drops it (upstream included), so records logged through theLoggerfacade behave exactly as before.eea624274) --muwas async.Mutexvalue, so every handler derived byWithAttrscreated its own mutex over the same writer. Make it a*sync.Mutexand hand the parent's mutex down, so a handler family serializes its writes.409aaefac) --WithAttrsappended toh.attrsdirectly, so when the parent's attribute slice had spare capacity two sibling handlers wrote into the same backing array and overwrote each other's attributes. Clone it first.This is a follow-up to #2825: the same attribute-aliasing class fixed there inside
internal/testlogalso existed in the productionTerminalHandler. It is kept in a separate PR because #2825 is test-only and already reviewed.Evidence
Mutation checks, one fix reverted at a time with the tests unchanged:
h.wr.Write(buf); return nil) --TestTerminalHandlerReportsWriteErrorsfails withHandle error is <nil>, want write refused.WithAttrshanding down&sync.Mutex{}--TestTerminalHandlerSharesMutexfails withsub-handler does not share the parent's mutex, andTestTerminalHandlerDerivedHandlerBlocksOnParentMutexfails withsub-handler wrote without waiting for the parent's mutex.append(h.attrs, attrs...)without the clone --TestTerminalHandlerKeepsSiblingAttributesfails withfirst child's attribute was overwritten: child="second".The mutex check is deterministic: the test holds the parent's mutex, so a derived handler with its own mutex writes through at once instead of blocking.
Validation
make allexits 0.gofmt/goimportsclean;go vet ./log/...passes.go test -count=1 ./log/...passes (four new tests plus the existing ones);go test -race ./log/passes.--new-from-rev=f85916e0c3 ./log/...(currentdev-upgradetip) -- 0 issues.origin/master(8817f99f9):log/handler.goidentical.Merge Danger
Door: two-way -- one production file with three independent hunks (error return, mutex pointer, clone) plus one additive test file. Reverting any hunk restores the previous behaviour byte for byte.
Blast Radius:
TerminalHandleris only built throughNewTerminalHandler/NewTerminalHandlerWithLevel(cmd/bootnode,cmd/abigen,cmd/puppeth,internal/debug/flags.go,p2p/simulations/adapters,p2p/simulations/examples(the ping-pong example program), plus tests); there are no struct literals outside the package, so every instance has an initializedmu. Behavioural deltas: sub-handlers now share the parent's mutex, andHandlereturns the writer error instead ofnil. No API or signature change.No file overlap with #2825 (
internal/testlog/*), so the two can be merged in any order.Ref: go-ethereum ethereum#35055 (
ab20d50db), ethereum#35074 (eea624274), ethereum#35141 (409aaefac)