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

It panic error occasionally #84

Closed
SunDrizzle opened this issue Mar 24, 2020 · 1 comment
Closed

It panic error occasionally #84

SunDrizzle opened this issue Mar 24, 2020 · 1 comment
Labels
priority: highest type: bug Something isn't working
Milestone

Comments

@SunDrizzle
Copy link

Describe the bug
I use beaver to build a socket server.But sometimes it panics with an error.
The error is : fatal error: concurrent map writes.

And the error's stacks info : github.com/clivern/beaver/internal/app/controller.(*Websocket).HandleConnections(0xc0001ca4d0, 0x7f033e218240, 0xc0004869a0, 0xc0000b1200, 0xc000233108, 0x24, 0xc00023312d, 0xbd, 0xc000029440, 0x24) /root/Beaver/internal/app/controller/socket.go:166 +0x505 fp=0xc000585688 sp=0xc0005854e8 pc=0xabd815.

The code in 166 line is:delete(e.Clients, ID)

I google for the reason and find it's unsafe that using map in goruntine. So I think Websocket.Clients should protected by mutex or use sync.Map directly?

Development or production environment

  • OS: [Ubuntu 16.04]
  • Go 1.12.17
@Clivern Clivern added the type: bug Something isn't working label Apr 4, 2020
@Clivern
Copy link
Owner

Clivern commented Apr 4, 2020

it is unsafe indeed since may be it got concurrent edits at same time, will check that on code

here is where the issue happen https://github.com/Clivern/Beaver/blob/master/internal/app/controller/socket.go#L166

@Clivern Clivern added this to the 2.0.0 milestone Jul 25, 2020
@Clivern Clivern mentioned this issue Oct 14, 2020
Clivern added a commit that referenced this issue Dec 29, 2020
Clivern added a commit that referenced this issue Dec 31, 2020
* fix issue #84 in v1.x.x

* rename

* update
@Clivern Clivern closed this as completed Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: highest type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants