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

Fix concurrent map writes in "ocpp1.6".centralSystem #56

Merged

Conversation

michaelbeaumont
Copy link
Contributor

I've run into the following error:

fatal error: concurrent map writes

goroutine 36 [running]:
runtime.throw(0xa98670, 0x15)
        /usr/lib/go/src/runtime/panic.go:1117 +0x72 fp=0xc0003ad788 sp=0xc0003ad758 pc=0x43a2b2
runtime.mapdelete_faststr(0x9b7800, 0xc00023fe90, 0xc000290004, 0xd)
        /usr/lib/go/src/runtime/map_faststr.go:382 +0x3a8 fp=0xc0003ad7f0 sp=0xc0003ad788 pc=0x416b48
github.com/lorenzodonini/ocpp-go/ocpp1%2e6.(*centralSystem).handleIncomingConfirmation(0xc0002b8f50, 0xc000290004, 0xd, 0xb38300, 0xc00040e460, 0xc0004082f0, 0xa)
        /home/mike/projects/project/vendor/github.com/lorenzodonini/ocpp-go/ocpp1.6/central_system.go:488 +0xbc fp=0xc0003ad9a0 sp=0xc0003ad7f0 pc=0x91badc

[truncated]

gorilla/websocket is running these handlers concurrently and access to callbacks should thus be protected by a Mutex.
This may also be an issue with the other packages, which I haven't looked at yet.

@lorenzodonini
Copy link
Owner

Actually, the panic may even be triggered by the application itself (regardless of the networking layer), if multiple goroutines attempt to send requests at the same time, so definitely worth having the mutex in place.

Nice catch, thanks!

@lorenzodonini lorenzodonini merged commit 40a8792 into lorenzodonini:master Apr 7, 2021
@michaelbeaumont michaelbeaumont deleted the ocpp16_concurrent_writes branch April 7, 2021 20:27
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

Successfully merging this pull request may close these issues.

None yet

2 participants