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 ireturn #63

Closed
hansgylling opened this issue Oct 17, 2023 · 2 comments · Fixed by #64 or #67
Closed

Data race in ireturn #63

hansgylling opened this issue Oct 17, 2023 · 2 comments · Fixed by #64 or #67
Assignees

Comments

@hansgylling
Copy link
Contributor

I found a data race in ireturn. Here's a terminal session where I reproduce it. I'm using the ireturn command to analyze the ireturn code.

$ cd ireturn
$ go version
go version go1.21.3 linux/amd64
$ git pull
Already up-to-date.
$ git status
On branch main
Your branch is up-to-date with 'origin/main'.
nothing to commit, working tree clean
$ go build -race -trimpath -o ireturn cmd/ireturn/main.go
$ ./ireturn ./...
==================
WARNING: DATA RACE
Read at 0x00c000a00058 by goroutine 1701:
  github.com/butuzov/ireturn/analyzer/internal/config.(*defaultConfig).Has()
      github.com/butuzov/ireturn/analyzer/internal/config/config.go:22 +0x7c
  github.com/butuzov/ireturn/analyzer/internal/config.(*allowConfig).IsValid()
      github.com/butuzov/ireturn/analyzer/internal/config/allow.go:16 +0xb9
  github.com/butuzov/ireturn/analyzer.(*analyzer).run.func3()
      github.com/butuzov/ireturn/analyzer/analyzer.go:73 +0x2e8
  golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder()
      golang.org/x/tools@v0.14.0/go/ast/inspector/inspector.go:82 +0x111
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn/analyzer/analyzer.go:53 +0x2a4
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  golang.org/x/tools/go/analysis/internal/checker.(*action).execOnce()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:767 +0x1641
  golang.org/x/tools/go/analysis/internal/checker.(*action).execOnce-fm()
      <autogenerated>:1 +0x33
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  golang.org/x/tools/go/analysis/internal/checker.(*action).exec()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:683 +0x4e
  golang.org/x/tools/go/analysis/internal/checker.execAll.func1()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:671 +0x26
  golang.org/x/tools/go/analysis/internal/checker.execAll.func2()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:677 +0x41

Previous write at 0x00c000a00058 by goroutine 1700:
  github.com/butuzov/ireturn/analyzer/internal/config.(*defaultConfig).Has()
      github.com/butuzov/ireturn/analyzer/internal/config/config.go:24 +0x9c
  github.com/butuzov/ireturn/analyzer/internal/config.(*allowConfig).IsValid()
      github.com/butuzov/ireturn/analyzer/internal/config/allow.go:16 +0xb9
  github.com/butuzov/ireturn/analyzer.(*analyzer).run.func3()
      github.com/butuzov/ireturn/analyzer/analyzer.go:73 +0x2e8
  golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder()
      golang.org/x/tools@v0.14.0/go/ast/inspector/inspector.go:82 +0x111
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn/analyzer/analyzer.go:53 +0x2a4
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  golang.org/x/tools/go/analysis/internal/checker.(*action).execOnce()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:767 +0x1641
  golang.org/x/tools/go/analysis/internal/checker.(*action).execOnce-fm()
      <autogenerated>:1 +0x33
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  golang.org/x/tools/go/analysis/internal/checker.(*action).exec()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:683 +0x4e
  golang.org/x/tools/go/analysis/internal/checker.execAll.func1()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:671 +0x26
  golang.org/x/tools/go/analysis/internal/checker.execAll.func2()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:677 +0x41

Goroutine 1701 (running) created at:
  golang.org/x/tools/go/analysis/internal/checker.execAll()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:677 +0x225
  golang.org/x/tools/go/analysis/internal/checker.analyze()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:311 +0x228
  golang.org/x/tools/go/analysis/internal/checker.Run()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:146 +0xb94
  golang.org/x/tools/go/analysis/singlechecker.Main()
      golang.org/x/tools@v0.14.0/go/analysis/singlechecker/singlechecker.go:75 +0x3c8
  main.main()
      main.go:9 +0x24

Goroutine 1700 (finished) created at:
  golang.org/x/tools/go/analysis/internal/checker.execAll()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:677 +0x225
  golang.org/x/tools/go/analysis/internal/checker.analyze()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:311 +0x228
  golang.org/x/tools/go/analysis/internal/checker.Run()
      golang.org/x/tools@v0.14.0/go/analysis/internal/checker/checker.go:146 +0xb94
  golang.org/x/tools/go/analysis/singlechecker.Main()
      golang.org/x/tools@v0.14.0/go/analysis/singlechecker/singlechecker.go:75 +0x3c8
  main.main()
      main.go:9 +0x24
==================
Found 1 data race(s)

It's also possible to trigger the data race when running ireturn through golangci-lint. That data race doesn't happen when trying to analyze the ireturn code repo, so I will show it by running it on the golangci-lint code instead.

$ cd golangci-lint
$ go build -race -trimpath -o golangci-lint cmd/golangci-lint/main.go
$ ./golangci-lint run --no-config --disable-all -E ireturn
==================
WARNING: DATA RACE
Read at 0x00c0000cda20 by goroutine 6238:
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:91 +0x2c4
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:195 +0x15a3
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:113 +0x2e
  github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage()
      github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x56
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x11a
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x189
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func4()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:81 +0x41

Previous write at 0x00c0000cda20 by goroutine 6236:
  github.com/butuzov/ireturn/analyzer.(*analyzer).run.func3()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:86 +0x608
  golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder()
      golang.org/x/tools@v0.14.0/go/ast/inspector/inspector.go:82 +0x111
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:53 +0x2a4
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:195 +0x15a3
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:113 +0x2e
  github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage()
      github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x56
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x11a
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x189
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func4()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:81 +0x41

Goroutine 6238 (running) created at:
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x336
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:48 +0x2dc
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:37 +0x6f
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:274 +0x64
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func3()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:276 +0x41

Goroutine 6236 (finished) created at:
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x336
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:48 +0x2dc
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:37 +0x6f
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1.1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:43 +0x4b
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1.2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:45 +0x41
==================
==================
WARNING: DATA RACE
Read at 0x00c00429c690 by goroutine 6238:
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:92 +0x364
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:195 +0x15a3
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:113 +0x2e
  github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage()
      github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x56
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x11a
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x189
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func4()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:81 +0x41

Previous write at 0x00c00429c690 by goroutine 6236:
  github.com/butuzov/ireturn/analyzer.(*analyzer).run.func3()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:86 +0x5b3
  golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder()
      golang.org/x/tools@v0.14.0/go/ast/inspector/inspector.go:82 +0x111
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:53 +0x2a4
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:195 +0x15a3
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:113 +0x2e
  github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage()
      github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x56
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x11a
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x189
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func4()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:81 +0x41

Goroutine 6238 (running) created at:
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x336
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:48 +0x2dc
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:37 +0x6f
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:274 +0x64
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func3()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:276 +0x41

Goroutine 6236 (finished) created at:
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x336
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:48 +0x2dc
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:37 +0x6f
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1.1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:43 +0x4b
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1.2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:45 +0x41
==================
==================
WARNING: DATA RACE
Write at 0x00c0000cda20 by goroutine 6284:
  github.com/butuzov/ireturn/analyzer.(*analyzer).run.func3()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:86 +0x608
  golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder()
      golang.org/x/tools@v0.14.0/go/ast/inspector/inspector.go:82 +0x111
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:53 +0x2a4
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:195 +0x15a3
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:113 +0x2e
  github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage()
      github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x56
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x11a
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x189
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func4()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:81 +0x41

Previous read at 0x00c0000cda20 by goroutine 6282:
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:92 +0x408
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:195 +0x15a3
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:113 +0x2e
  github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage()
      github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x56
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x11a
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x189
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func4()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:81 +0x41

Goroutine 6284 (running) created at:
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x336
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:48 +0x2dc
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:37 +0x6f
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:274 +0x64
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func3()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:276 +0x41

Goroutine 6282 (finished) created at:
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x336
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:48 +0x2dc
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:37 +0x6f
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:274 +0x64
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func3()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:276 +0x41
==================
==================
WARNING: DATA RACE
Read at 0x00c004c20d98 by goroutine 6290:
  runtime.growslice()
      runtime/slice.go:157 +0x0
  github.com/butuzov/ireturn/analyzer.(*analyzer).run.func3()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:86 +0x57d
  golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder()
      golang.org/x/tools@v0.14.0/go/ast/inspector/inspector.go:82 +0x111
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:53 +0x2a4
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:195 +0x15a3
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:113 +0x2e
  github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage()
      github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x56
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x11a
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x189
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func4()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:81 +0x41

Previous write at 0x00c004c20d98 by goroutine 6284:
  github.com/butuzov/ireturn/analyzer.(*analyzer).run.func3()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:86 +0x5b3
  golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder()
      golang.org/x/tools@v0.14.0/go/ast/inspector/inspector.go:82 +0x111
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:53 +0x2a4
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:195 +0x15a3
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:113 +0x2e
  github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage()
      github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x56
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x11a
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x189
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func4()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:81 +0x41

Goroutine 6290 (running) created at:
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x336
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:48 +0x2dc
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:37 +0x6f
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:274 +0x64
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func3()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:276 +0x41

Goroutine 6284 (finished) created at:
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x336
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:48 +0x2dc
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:37 +0x6f
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:274 +0x64
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func3()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:276 +0x41
==================
==================
WARNING: DATA RACE
Read at 0x00c0000cda20 by goroutine 6298:
  github.com/butuzov/ireturn/analyzer.(*analyzer).run.func3()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:86 +0x544
  golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder()
      golang.org/x/tools@v0.14.0/go/ast/inspector/inspector.go:82 +0x111
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:53 +0x2a4
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:195 +0x15a3
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:113 +0x2e
  github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage()
      github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x56
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x11a
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x189
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func4()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:81 +0x41

Previous write at 0x00c0000cda20 by goroutine 6295:
  github.com/butuzov/ireturn/analyzer.(*analyzer).run.func3()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:86 +0x608
  golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder()
      golang.org/x/tools@v0.14.0/go/ast/inspector/inspector.go:82 +0x111
  github.com/butuzov/ireturn/analyzer.(*analyzer).run()
      github.com/butuzov/ireturn@v0.2.0/analyzer/analyzer.go:53 +0x2a4
  github.com/butuzov/ireturn/analyzer.(*analyzer).run-fm()
      <autogenerated>:1 +0x3d
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:195 +0x15a3
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:113 +0x2e
  github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage()
      github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x56
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x11a
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x189
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func4()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:81 +0x41

Goroutine 6298 (running) created at:
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x336
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:48 +0x2dc
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:37 +0x6f
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:274 +0x64
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func3()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:276 +0x41

Goroutine 6295 (finished) created at:
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x336
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive.func1()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:48 +0x2dc
  sync.(*Once).doSlow()
      sync/once.go:74 +0xf0
  sync.(*Once).Do()
      sync/once.go:65 +0x44
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyzeRecursive()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:37 +0x6f
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func2()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:274 +0x64
  github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*runner).analyze.func3()
      github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner.go:276 +0x41
==================
pkg/logutils/mock.go:40:1: Child returns interface (github.com/golangci/golangci-lint/pkg/logutils.Log) (ireturn)
func (m *MockLog) Child(name string) Log {
^
pkg/logutils/stderr_log.go:115:1: Child returns interface (github.com/golangci/golangci-lint/pkg/logutils.Log) (ireturn)
func (sl StderrLog) Child(name string) Log {
^
pkg/report/log.go:50:1: Child returns interface (github.com/golangci/golangci-lint/pkg/logutils.Log) (ireturn)
func (lw LogWrapper) Child(name string) logutils.Log {
^
pkg/printers/github.go:18:1: NewGithub returns interface (github.com/golangci/golangci-lint/pkg/printers.Printer) (ireturn)
func NewGithub(w io.Writer) Printer {
^
pkg/lint/runner.go:257:1: getExcludeProcessor returns interface (github.com/golangci/golangci-lint/pkg/result/processors.Processor) (ireturn)
func getExcludeProcessor(cfg *config.Issues) processors.Processor {
^
pkg/lint/runner.go:274:1: getExcludeRulesProcessor returns interface (github.com/golangci/golangci-lint/pkg/result/processors.Processor) (ireturn)
func getExcludeRulesProcessor(cfg *config.Issues, log logutils.Log, files *fsutils.Files) processors.Processor {
^
pkg/lint/runner.go:317:1: getSeverityRulesProcessor returns interface (github.com/golangci/golangci-lint/pkg/result/processors.Processor) (ireturn)
func getSeverityRulesProcessor(cfg *config.Severity, log logutils.Log, files *fsutils.Files) processors.Processor {
^
pkg/golinters/goanalysis/runner_facts.go:79:1: codeFact returns interface (golang.org/x/tools/go/analysis.Fact) (ireturn)
func codeFact(fact analysis.Fact) (analysis.Fact, error) {
^
pkg/commands/run.go:460:1: createPrinter returns interface (github.com/golangci/golangci-lint/pkg/printers.Printer) (ireturn)
func (e *Executor) createPrinter(format string, w io.Writer) (printers.Printer, error) {
^
pkg/result/processors/sort_results.go:93:1: Next returns interface (github.com/golangci/golangci-lint/pkg/result/processors.comparator) (ireturn)
func (cmp ByName) Next() comparator { return cmp.next }
^
pkg/result/processors/sort_results.go:111:1: Next returns interface (github.com/golangci/golangci-lint/pkg/result/processors.comparator) (ireturn)
func (cmp ByLine) Next() comparator { return cmp.next }
^
pkg/result/processors/sort_results.go:129:1: Next returns interface (github.com/golangci/golangci-lint/pkg/result/processors.comparator) (ireturn)
func (cmp ByColumn) Next() comparator { return cmp.next }
^

The stack trace looks similar to the data race bug I reported in May for the mirror tool (butuzov/mirror#17). Hopefully the same technique can be used to fix this problem in ireturn.

I hope you will have some time to fix this, but I understand if it might take a while, or perhaps, a long time. I wish you and your country luck in your struggles.

@butuzov butuzov self-assigned this Oct 18, 2023
@butuzov
Copy link
Owner

butuzov commented Oct 18, 2023

Thank you for noticing this. BTW, is codebase you testing it is public?

butuzov added a commit that referenced this issue Oct 18, 2023
butuzov added a commit that referenced this issue Oct 18, 2023
@butuzov
Copy link
Owner

butuzov commented Oct 18, 2023

Bug is still there, reopening.

@butuzov butuzov reopened this Oct 18, 2023
butuzov added a commit that referenced this issue Oct 18, 2023
Resolves: #63
@butuzov butuzov mentioned this issue Oct 18, 2023
butuzov added a commit that referenced this issue Oct 18, 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 a pull request may close this issue.

2 participants