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

client/core: resolve xcWallet.peerCount race (parent part) #2178

Conversation

norwnd
Copy link
Contributor

@norwnd norwnd commented Feb 27, 2023

Race detector found another race I missed (this one is a bit more involved, having to do with reading parent wallet state without acquiring parent mutex) when addressing similar one.

WARNING: DATA RACE
Write at 0x00c00047a300 by goroutine 5580:
  decred.org/dcrdex/client/core.(*xcWallet).Lock()
      /Users/norwnd/dcrdex/client/core/wallet.go:193 +0x1f5
  decred.org/dcrdex/client/core.(*xcWallet).Lock()
      /Users/norwnd/dcrdex/client/core/wallet.go:181 +0x184
  decred.org/dcrdex/client/core.(*Core).Logout()
      /Users/norwnd/dcrdex/client/core/core.go:4735 +0x352
  main.promptShutdown.func1()
      /Users/norwnd/dcrdex/client/cmd/dexc/main.go:241 +0x3d

Previous read at 0x00c00047a300 by goroutine 61:
  decred.org/dcrdex/client/core.(*xcWallet).state()
      /Users/norwnd/dcrdex/client/core/wallet.go:271 +0x217
  decred.org/dcrdex/client/core.(*Core).assetMap()
      /Users/norwnd/dcrdex/client/core/core.go:2258 +0x727
  decred.org/dcrdex/client/core.(*Core).SupportedAssets()
      /Users/norwnd/dcrdex/client/core/core.go:2209 +0x189
  decred.org/dcrdex/client/core.(*Core).refreshFiatRates()
      /Users/norwnd/dcrdex/client/core/core.go:9744 +0x17c
  decred.org/dcrdex/client/core.(*Core).fetchFiatExchangeRates.func1()
      /Users/norwnd/dcrdex/client/core/core.go:9725 +0x14e

@norwnd
Copy link
Contributor Author

norwnd commented Feb 27, 2023

Whoops, forgot to add the main change itself, here it is: 835df7c,

so all 3 commits can be squashed before merging to master, can you do this on merge or do I need to force-push for this myself (just so I know in future) ?

@chappjc
Copy link
Member

chappjc commented Feb 27, 2023

so all 3 commits can be squashed before merging to master, can you do this on merge or do I need to force-push for this myself (just so I know in future) ?

It's fine to squash in this case (just put up the pr and did change X followed by undo change X, so just squash). I like to have separate commits when either:

  • they are conceptually separate and aid review, and I intend to have them merged separately
  • they are review updates, which I generally squash after the reviewer has seen them.

Copy link
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

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

LGTM.

I need to get back to running with the race detector more often.

In addition to finding data races, it also has the side effect of making you acutely aware of operations that can get slow, especially on mainnet or testnet or large wallets. Just playing around on simnet hides many real life bottlenecks, so I'm glad you spend time working with testnet.

@chappjc chappjc merged commit 6fdd873 into decred:master Feb 28, 2023
@chappjc chappjc added this to the 0.6 milestone Mar 1, 2023
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.

None yet

3 participants