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 A race condition in the scd4x driver.
To Reproduce
go test -race, e.g. Example: https://github.com/periph/devices/actions/runs/12216048416/job/34078745883?pr=8
go test -race
================== WARNING: DATA RACE Read at 0x00c000218078 by goroutine 18: periph.io/x/devices/v3/scd4x.(*Dev).Sense() D:/a/devices/devices/scd4x/scd4x.go:533 +0xd9 periph.io/x/devices/v3/scd4x.(*Dev).SenseContinuous.func1() D:/a/devices/devices/scd4x/scd4x.go:600 +0x351 Previous write at 0x00c000218078 by goroutine 19: periph.io/x/devices/v3/scd4x.(*Dev).Halt() D:/a/devices/devices/scd4x/scd4x.go:373 +0x[133](https://github.com/periph/devices/actions/runs/12216048416/job/34078745883?pr=83#step:9:134) periph.io/x/devices/v3/scd4x.TestSenseContinuous.func2() D:/a/devices/devices/scd4x/scd4x_test.go:257 +0x4f Goroutine 18 (running) created at: periph.io/x/devices/v3/scd4x.(*Dev).SenseContinuous() D:/a/devices/devices/scd4x/scd4x.go:583 +0x1bb periph.io/x/devices/v3/scd4x.TestSenseContinuous() D:/a/devices/devices/scd4x/scd4x_test.go:250 +0x33c testing.tRunner() C:/hostedtoolcache/windows/go/1.22.6/x64/src/testing/testing.go:1689 +0x21e testing.(*T).Run.gowrap1() C:/hostedtoolcache/windows/go/1.22.6/x64/src/testing/testing.go:1742 +0x44 Goroutine 19 (running) created at: periph.io/x/devices/v3/scd4x.TestSenseContinuous() D:/a/devices/devices/scd4x/scd4x_test.go:255 +0x479 testing.tRunner() C:/hostedtoolcache/windows/go/1.22.6/x64/src/testing/testing.go:1689 +0x21e testing.(*T).Run.gowrap1() C:/hostedtoolcache/windows/go/1.22.6/x64/src/testing/testing.go:1742 +0x44 ==================
https://github.com/periph/devices/blob/main/scd4x/scd4x.go#L533 https://github.com/periph/devices/blob/main/scd4x/scd4x.go#L373
Fix
Add a d.mu.Lock() + Unlock around line 533 when reading d.sensing.
The text was updated successfully, but these errors were encountered:
72857e8
No branches or pull requests
Describe the bug
A race condition in the scd4x driver.
To Reproduce
go test -race
, e.g. Example: https://github.com/periph/devices/actions/runs/12216048416/job/34078745883?pr=8https://github.com/periph/devices/blob/main/scd4x/scd4x.go#L533
https://github.com/periph/devices/blob/main/scd4x/scd4x.go#L373
Fix
Add a d.mu.Lock() + Unlock around line 533 when reading d.sensing.
The text was updated successfully, but these errors were encountered: