Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common/txmgr: initialize map before goroutines race ahead #11452

Merged
merged 2 commits into from
Dec 1, 2023

Conversation

jmank88
Copy link
Contributor

@jmank88 jmank88 commented Dec 1, 2023

This PR reorders the statements in *Broadcaster.startInternal() so that the nextSequenceMap is initialized before the spawned goroutines have an opportunity to race ahead and access it.

$ go test ./core/chains/evm/txmgr/ -race -count 5
panic: assignment to entry in nil map

goroutine 1805 [running]:
github.com/smartcontractkit/chainlink/v2/common/txmgr.(*Broadcaster[...]).GetNextSequence(0x43dfdc0, {0x43b5538, 0xc002798410}, {0x80, 0xf7, 0x22, 0x1b, 0x6a, 0x3a, 0xce, ...})
        /home/jordan/chainlink/common/txmgr/broadcaster.go:826 +0x5ed
github.com/smartcontractkit/chainlink/v2/common/txmgr.(*Broadcaster[...]).SyncSequence(0x43dfdc0, {0x43b5538, 0xc002798410}, {0x80, 0xf7, 0x22, 0x1b, 0x6a, 0x3a, 0xce, ...})
        /home/jordan/chainlink/common/txmgr/broadcaster.go:403 +0x149
github.com/smartcontractkit/chainlink/v2/common/txmgr.(*Broadcaster[...]).monitorTxs(0x43dfdc0, {0x80, 0xf7, 0x22, 0x1b, 0x6a, 0x3a, 0xce, 0x50, 0xce, ...}, ...)
        /home/jordan/chainlink/common/txmgr/broadcaster.go:347 +0x3ee
created by github.com/smartcontractkit/chainlink/v2/common/txmgr.(*Broadcaster[...]).startInternal in goroutine 1804
        /home/jordan/chainlink/common/txmgr/broadcaster.go:228 +0x7cf
FAIL    github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr  117.452s
FAIL

Copy link
Contributor

github-actions bot commented Dec 1, 2023

I see that you haven't updated any CHANGELOG files. Would it make sense to do so?

samsondav
samsondav previously approved these changes Dec 1, 2023
@jmank88 jmank88 changed the title common/txmgr: initiliaze map before goroutines race ahead common/txmgr: initialize map before goroutines race ahead Dec 1, 2023
@cl-sonarqube-production
Copy link

@jmank88 jmank88 marked this pull request as ready for review December 1, 2023 19:57
Copy link
Contributor

@amit-momin amit-momin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for handling this!

@jmank88 jmank88 added this pull request to the merge queue Dec 1, 2023
Merged via the queue into develop with commit b8084cb Dec 1, 2023
87 checks passed
@jmank88 jmank88 deleted the txm-broadcaster-nil-map branch December 1, 2023 20:44
fbac pushed a commit that referenced this pull request Dec 14, 2023
* common/txmgr: initiliaze map before goroutines race ahead

* pass ctx from Start()
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.

4 participants