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

ocppj logger is racy #309

Open
andig opened this issue Oct 28, 2024 · 0 comments
Open

ocppj logger is racy #309

andig opened this issue Oct 28, 2024 · 0 comments

Comments

@andig
Copy link
Contributor

andig commented Oct 28, 2024

OCPP version:
[x] 1.6
[ ] 2.0.1

I'm submitting a ...

[x] bug report
[ ] feature request

Current behavior:

See this -race test;

==================
WARNING: DATA RACE
Write at 0x00010836e370 by goroutine 80:
  github.com/lorenzodonini/ocpp-go/ocppj.SetLogger()
      /Users/andig/go/pkg/mod/github.com/evcc-io/ocpp-go@v0.0.0-20240914122959-0d109e403130/ocppj/ocppj.go:43 +0x50
  github.com/evcc-io/evcc/charger.(*ocppTestSuite).SetupTest()
      /Users/andig/htdocs/evcc/charger/ocpp_test.go:41 +0x44
  github.com/stretchr/testify/suite.Run.func1()
      /Users/andig/go/pkg/mod/github.com/stretchr/testify@v1.9.0/suite/suite.go:192 +0x218
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.23.2/libexec/src/testing/testing.go:1690 +0x184
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.23.2/libexec/src/testing/testing.go:1743 +0x40

Previous read at 0x00010836e370 by goroutine 23:
  github.com/lorenzodonini/ocpp-go/ocppj.(*DefaultServerDispatcher).messagePump()
      /Users/andig/go/pkg/mod/github.com/evcc-io/ocpp-go@v0.0.0-20240914122959-0d109e403130/ocppj/dispatcher.go:556 +0x908
  github.com/lorenzodonini/ocpp-go/ocppj.(*DefaultServerDispatcher).Start.gowrap2()
      /Users/andig/go/pkg/mod/github.com/evcc-io/ocpp-go@v0.0.0-20240914122959-0d109e403130/ocppj/dispatcher.go:410 +0x34

SetLogger and accessing log would need to use a mutex. I'm not sure this is worth it though. If you think it is I'd be happy to open a PR.

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

No branches or pull requests

1 participant