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

bug: race condition from the clispinner #1265

Closed
Pantani opened this issue Jun 20, 2021 · 3 comments · Fixed by #1288
Closed

bug: race condition from the clispinner #1265

Pantani opened this issue Jun 20, 2021 · 3 comments · Fixed by #1288
Assignees
Labels

Comments

@Pantani
Copy link
Collaborator

Pantani commented Jun 20, 2021

Describe the bug
One race condition from the clispinner when you try to scaffold a new application

WARNING: DATA RACE
Read at 0x00c0011ea508 by goroutine 37:
  github.com/briandowns/spinner.(*Spinner).Start.func1()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/briandowns/spinner@v1.11.1/spinner.go:306 +0x424

Previous write at 0x00c0011ea508 by main goroutine:
  github.com/tendermint/starport/starport/pkg/clispinner.(*Spinner).SetText()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/pkg/clispinner/clispinner.go:32 +0xb0
  github.com/tendermint/starport/starport/pkg/clispinner.New()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/pkg/clispinner/clispinner.go:26 +0x21c
  github.com/tendermint/starport/starport/cmd.appHandler()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/cmd/app.go:33 +0x30
  github.com/spf13/cobra.(*Command).execute()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0xbcc
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x768
  github.com/spf13/cobra.(*Command).Execute()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897 +0x34
  github.com/spf13/cobra.(*Command).ExecuteContext()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:890 +0x88
  main.main()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/cmd/starport/main.go:40 +0x44c

Goroutine 37 (running) created at:
  github.com/briandowns/spinner.(*Spinner).Start()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/briandowns/spinner@v1.11.1/spinner.go:281 +0x1c8
  github.com/briandowns/spinner.(*Spinner).Restart()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/briandowns/spinner@v1.11.1/spinner.go:346 +0x3c
  github.com/briandowns/spinner.(*Spinner).Color()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/briandowns/spinner@v1.11.1/spinner.go:373 +0x2f4
  github.com/tendermint/starport/starport/pkg/clispinner.New()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/pkg/clispinner/clispinner.go:22 +0x198
  github.com/tendermint/starport/starport/cmd.appHandler()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/cmd/app.go:33 +0x30
  github.com/spf13/cobra.(*Command).execute()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0xbcc
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x768
  github.com/spf13/cobra.(*Command).Execute()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897 +0x34
  github.com/spf13/cobra.(*Command).ExecuteContext()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:890 +0x88
  main.main()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/cmd/starport/main.go:40 +0x44c

To Reproduce
Steps to reproduce the behavior:

  1. Scaffolding a new application with the Golang -race parameters active

Please provide the output of commands

  • starport version
    starport version development darwin/arm64 -build date: 2021-06-20T09:29:50
    git object hash: b64d943

  • go version
    go version go1.16.5 darwin/arm64

  • uname -a
    Darwin Danilos-MacBook-Air.local 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64

@Pantani Pantani added the report label Jun 20, 2021
@Pantani
Copy link
Collaborator Author

Pantani commented Jun 20, 2021

another one from the clispinner :

==================
WARNING: DATA RACE
Read at 0x00c0011ea4e0 by goroutine 56:
  github.com/briandowns/spinner.(*Spinner).Start.func1()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/briandowns/spinner@v1.11.1/spinner.go:283 +0x4c

Previous write at 0x00c0011ea4e0 by main goroutine:
  github.com/briandowns/spinner.(*Spinner).UpdateCharSet()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/briandowns/spinner@v1.11.1/spinner.go:388 +0xcc
  github.com/tendermint/starport/starport/pkg/clispinner.(*Spinner).SetCharset()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/pkg/clispinner/clispinner.go:44 +0x70
  github.com/tendermint/starport/starport/pkg/clispinner.(*Spinner).Stop()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/pkg/clispinner/clispinner.go:65 +0xf8
  github.com/tendermint/starport/starport/cmd.appHandler()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/cmd/app.go:51 +0x398
  github.com/spf13/cobra.(*Command).execute()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0xbcc
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x768
  github.com/spf13/cobra.(*Command).Execute()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897 +0x34
  github.com/spf13/cobra.(*Command).ExecuteContext()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:890 +0x88
  main.main()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/cmd/starport/main.go:40 +0x44c

Goroutine 56 (running) created at:
  github.com/briandowns/spinner.(*Spinner).Start()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/briandowns/spinner@v1.11.1/spinner.go:281 +0x1c8
  github.com/briandowns/spinner.(*Spinner).Restart()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/briandowns/spinner@v1.11.1/spinner.go:346 +0x3c
  github.com/briandowns/spinner.(*Spinner).Color()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/briandowns/spinner@v1.11.1/spinner.go:373 +0x2f4
  github.com/tendermint/starport/starport/pkg/clispinner.(*Spinner).SetColor()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/pkg/clispinner/clispinner.go:50 +0xc8
  github.com/tendermint/starport/starport/pkg/clispinner.(*Spinner).Stop()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/pkg/clispinner/clispinner.go:63 +0x8c
  github.com/tendermint/starport/starport/cmd.appHandler()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/cmd/app.go:51 +0x398
  github.com/spf13/cobra.(*Command).execute()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0xbcc
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x768
  github.com/spf13/cobra.(*Command).Execute()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897 +0x34
  github.com/spf13/cobra.(*Command).ExecuteContext()
      /Users/danilopantani/Desktop/Go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:890 +0x88
  main.main()
      /Users/danilopantani/Desktop/Go/src/github.com/tendermint/starport/starport/cmd/starport/main.go:40 +0x44c
==================

@Pantani
Copy link
Collaborator Author

Pantani commented Jun 21, 2021

@faddat and @ilgooz, my suggestion is to change the current spinner. There are too many bugs related to the data race. I reported here

@ilgooz
Copy link
Member

ilgooz commented Jun 22, 2021

@Pantani lets try using the Lock/Unlock API provided by the underlying spinner package, this should solve it. Basically we need to lock it when we set values like Prefix/Suffix, like the one here.

I think race here from the spinner is negligible but still it would be convenient to fix them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants