-
-
Notifications
You must be signed in to change notification settings - Fork 217
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Hello.
I have identified a data race on the pterm.SpinnerPrinter.
General information:
- pterm version: v0.12.57
- go version: v1.19.7
- os: windows
Steps to reproduce:
run following code with go run -race
p, err := pterm.DefaultSpinner.
WithShowTimer(false).
WithRemoveWhenDone(true).
Start("Doing stuff...")
if err != nil {
log.Fatalf("Start spinner failed: %s", err.Error())
}
time.Sleep(2 * time.Second)
err = p.Stop()
if err != nil {
log.Fatalf("Stop spinner failed: %s", err.Error())
}After inspecting the source code i have found out that the reason is the go routine, spawned in func (s SpinnerPrinter) Start(text ...interface{}) (*SpinnerPrinter, error)
Line 127 in 971fa81
| func (s SpinnerPrinter) Start(text ...interface{}) (*SpinnerPrinter, error) { |
IsActive field. Line 141 in 971fa81
| for s.IsActive { |
func (s *SpinnerPrinter) Stop() error writes to this field from anothe routine, and this causes a data race. Line 171 in 971fa81
| s.IsActive = false |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working