fix: add mutex lock in Info() ABCI method to prevent data race#26342
Open
srpatcha wants to merge 1 commit into
Open
fix: add mutex lock in Info() ABCI method to prevent data race#26342srpatcha wants to merge 1 commit into
srpatcha wants to merge 1 commit into
Conversation
Contributor
|
PR author is not in the allowed authors list. |
Author
|
Hi maintainers, this PR is awaiting maintainer approval to run the GitHub Actions workflows (the |
dd3c589 to
6640cc9
Compare
Info() in baseapp/abci.go reads shared fields (cms, name, version) without acquiring app.mu, while other methods like InitChain() modify these fields under the mutex. This creates a data race during startup when CometBFT calls Info() and InitChain() concurrently. Added app.mu.Lock() and defer app.mu.Unlock() at the start of Info(), matching the pattern used by other ABCI methods.
6640cc9 to
9a2a0a3
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.
Description
\Info()\ in \�aseapp/abci.go\ reads shared fields (\cms, ame, \�ersion) without acquiring \�pp.mu, while other methods like \InitChain()\ modify these fields under the mutex. This creates a data race.
Root Cause
The \BaseApp\ struct uses \�pp.mu\ to protect concurrent access to its fields. Methods like \InitChain(), \FinalizeBlock(), and \Commit()\ properly lock \�pp.mu\ before accessing shared state. However, \Info()\ — called by CometBFT during handshake and queries — reads \�pp.cms, \�pp.name, and \�pp.version\ without locking.
Fix
Added \�pp.mu.Lock()\ and \defer app.mu.Unlock()\ at the start of \Info(), matching the pattern used by other ABCI methods.
Testing
Impact
Affects Cosmos SDK node operators. The data race is most likely during startup (when \InitChain\ and \Info\ may be called concurrently) and could cause reading inconsistent app state.
Closes #26321 (previous PR closed due to unsigned commits — this PR uses GPG-signed commits).