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

Data race in depinject #12439

Closed
4 tasks
julienrbrt opened this issue Jul 4, 2022 · 2 comments · Fixed by #12484
Closed
4 tasks

Data race in depinject #12439

julienrbrt opened this issue Jul 4, 2022 · 2 comments · Fixed by #12484
Labels
C:depinject Issues and PR related to depinject T:Bug

Comments

@julienrbrt
Copy link
Member

julienrbrt commented Jul 4, 2022

Summary of Bug

There is a data race in depinject which makes our CI failing. Here is the test dump:

==================
WARNING: DATA RACE
Read at 0x00c00040b270 by goroutine 20:
  runtime.racereadrange()
      <autogenerated>:1 +0x1b
  github.com/cosmos/cosmos-sdk/depinject.ExtractProviderDescriptor()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/provider_desc.go:47 +0x2c4
  github.com/cosmos/cosmos-sdk/depinject.invoke()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/config.go:78 +0x10a
  github.com/cosmos/cosmos-sdk/depinject.InvokeInModule.func1()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/config.go:72 +0x1b3
  github.com/cosmos/cosmos-sdk/depinject.containerConfig.apply()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/config.go:[169](https://github.com/cosmos/cosmos-sdk/runs/7183566391?check_suite_focus=true#step:7:170) +0x36
  github.com/cosmos/cosmos-sdk/depinject.Configs.func1()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/config.go:157 +0x92
  github.com/cosmos/cosmos-sdk/depinject.containerConfig.apply()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/config.go:169 +0x36
  github.com/cosmos/cosmos-sdk/depinject.doInject()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/inject.go:73 +0x427
  github.com/cosmos/cosmos-sdk/depinject.inject()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/inject.go:44 +0x4d7
  github.com/cosmos/cosmos-sdk/depinject.Inject()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/inject.go:18 +0x94
  github.com/cosmos/cosmos-sdk/x/auth/client_test.TestBatchScanner_Scan()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/x/auth/client/tx_test.go:103 +0x113
  testing.tRunner()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1439 +0x213
  testing.(*T).Run.func1()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1486 +0x47
Previous write at 0x00c00040b270 by goroutine 19:
  github.com/cosmos/cosmos-sdk/depinject.(*container).addInvoker()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/container.go:371 +0x310
  github.com/cosmos/cosmos-sdk/depinject.invoke()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/config.go:82 +0x269
  github.com/cosmos/cosmos-sdk/depinject.InvokeInModule.func1()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/config.go:72 +0x1b3
  github.com/cosmos/cosmos-sdk/depinject.containerConfig.apply()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/config.go:169 +0x36
  github.com/cosmos/cosmos-sdk/depinject.Configs.func1()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/config.go:157 +0x92
  github.com/cosmos/cosmos-sdk/depinject.containerConfig.apply()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/config.go:169 +0x36
  github.com/cosmos/cosmos-sdk/depinject.doInject()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/inject.go:73 +0x427
  github.com/cosmos/cosmos-sdk/depinject.inject()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/inject.go:44 +0x4d7
  github.com/cosmos/cosmos-sdk/depinject.Inject()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/depinject/inject.go:18 +0x94
  github.com/cosmos/cosmos-sdk/x/auth/client_test.TestReadTxFromFile()
      /home/ubuntu/actions-runner/_work/cosmos-sdk/cosmos-sdk/x/auth/client/tx_test.go:64 +0x19e
  testing.tRunner()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1439 +0x213
  testing.(*T).Run.func1()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1486 +0x47
Goroutine 20 (running) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1486 +0x724
  testing.runTests.func1()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1839 +0x99
  testing.tRunner()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1439 +0x213
  testing.runTests()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1837 +0x7e4
  testing.(*M).Run()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:[171](https://github.com/cosmos/cosmos-sdk/runs/7183566391?check_suite_focus=true#step:7:172)9 +0xa71
  main.main()
      _testmain.go:55 +0x2e4
Goroutine 19 (running) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1486 +0x724
  testing.runTests.func1()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:[183](https://github.com/cosmos/cosmos-sdk/runs/7183566391?check_suite_focus=true#step:7:184)9 +0x99
  testing.tRunner()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1439 +0x213
  testing.runTests()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1837 +0x7e4
  testing.(*M).Run()
      /opt/hostedtoolcache/go/1.18.3/x64/src/testing/testing.go:1719 +0xa71
  main.main()
      _testmain.go:55 +0x2e4
==================
--- FAIL: TestReadTxFromFile (0.02s)
    tx_test.go:94: &{0xc0005f9c10 0xc00021e930 [] [] false}
    tx_test.go:95: &{<nil> 0xc00021eea0 [] [] false}
    testing.go:1312: race detected during execution of test
--- FAIL: TestBatchScanner_Scan (0.02s)
    testing.go:1312: race detected during execution of test
FAIL
FAIL	github.com/cosmos/cosmos-sdk/x/auth/client	0.502s

Version

main

Steps to Reproduce

See https://github.com/cosmos/cosmos-sdk/runs/7183566391?check_suite_focus=true

To reproduce locally:

cd x/auth/client
go test -race # run this repeatedly until failure

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@julienrbrt julienrbrt added T:Bug C:depinject Issues and PR related to depinject labels Jul 4, 2022
@julienrbrt julienrbrt changed the title Test race in depinject Data race in depinject Jul 4, 2022
@robert-zaremba
Copy link
Collaborator

BTW, same failure happens in

cosmos-sdk/client/grpc/tmservice main* ❯ go test -timeout 40s -race

Randomly fails.

@alexanderbez
Copy link
Contributor

Yes, @robert-zaremba we know. We have an issue for that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:depinject Issues and PR related to depinject T:Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants