We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug The loadErr variable is read and written simultaneously
loadErr
gopsutil/load/load_windows.go
Lines 16 to 23 in c806740
Lines 46 to 54 in c806740
Lines 72 to 85 in c806740
================== WARNING: DATA RACE Write at 0x000143310d10 by goroutine 33: github.com/shirou/gopsutil/v3/load.loadAvgGoroutine.func1() github.com/shirou/gopsutil/[email protected]/load/load_windows.go:48 +0x13a github.com/shirou/gopsutil/v3/load.loadAvgGoroutine() github.com/shirou/gopsutil/[email protected]/load/load_windows.go:62 +0x338 github.com/shirou/gopsutil/v3/load.AvgWithContext.func1.1() github.com/shirou/gopsutil/[email protected]/load/load_windows.go:74 +0x44 Previous read at 0x000143310d10 by goroutine 34: github.com/shirou/gopsutil/v3/load.AvgWithContext() github.com/shirou/gopsutil/[email protected]/load/load_windows.go:84 +0x1a4 github.com/shirou/gopsutil/v3/load.Avg() github.com/shirou/gopsutil/[email protected]/load/load_windows.go:69 +0x84 kitchenette/internal/app/service/sstat.readloadF() ts/xxxx.go:30 +0x8a kitchenette/internal/app/service/sstat.readload() ts/xxxx.go:24 +0xcb Goroutine 33 (running) created at: github.com/shirou/gopsutil/v3/load.AvgWithContext.func1() github.com/shirou/gopsutil/[email protected]/load/load_windows.go:74 +0xa4 sync.(*Once).doSlow() sync/once.go:74 +0xf0 sync.(*Once).Do() sync/once.go:65 +0x44 github.com/shirou/gopsutil/v3/load.AvgWithContext() github.com/shirou/gopsutil/[email protected]/load/load_windows.go:73 +0xa4 github.com/shirou/gopsutil/v3/load.Avg() github.com/shirou/gopsutil/[email protected]/load/load_windows.go:69 +0x84 ts/xxxx.readloadF() ts/xxxx.go:30 +0x8a ts/xxxx.init.4() ts/xxxx.go:16 +0x8a Goroutine 34 (running) created at: ts/xxxx.init.4() ts/xxxx.go:17 +0x96 ==================
To Reproduce It will take about 10 minutes to wait.
var statlock sync.RWMutex func init() { readloadF() go readload() } func readload() { loadTicker := time.NewTicker( 5 * time.Second) defer loadTicker.Stop() for range loadTicker.C { readloadF() } } func readloadF() { statlock.Lock() defer statlock.Unlock() load.Avg() load.Misc() }
Expected behavior No data race.
Environment (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered:
[load][windows] Fix DATA RACE in load. Avg()
03d43fb
fixed shirou#1526
Successfully merging a pull request may close this issue.
Describe the bug
The
loadErr
variable is read and written simultaneouslygopsutil/load/load_windows.go
Lines 16 to 23 in c806740
gopsutil/load/load_windows.go
Lines 46 to 54 in c806740
gopsutil/load/load_windows.go
Lines 72 to 85 in c806740
To Reproduce
It will take about 10 minutes to wait.
Expected behavior
No data race.
Environment (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: