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

bugfix(client): Fix the panic due to concurrent writing #180

Merged

Conversation

xaionaro
Copy link
Contributor

@xaionaro xaionaro commented Oct 18, 2024

bugfix(client): Fix the panic due to concurrent writing

The bug:

        panic: concurrent write to websocket connection
        goroutine 66624 [running]:
        github.com/gorilla/websocket.(*messageWriter).flushFrame(0xc001ad7ef0, 0x1, {0x0?, 0x0?, 0x0?})
                /home/streampanel/go/pkg/mod/github.com/gorilla/websocket@v1.5.3/conn.go:617 +0x4b8
        github.com/gorilla/websocket.(*messageWriter).Close(0xc001e12f60?)
                /home/streampanel/go/pkg/mod/github.com/gorilla/websocket@v1.5.3/conn.go:731 +0x35
        github.com/gorilla/websocket.(*Conn).beginMessage(0xc001e034a0, 0xc001e12f60, 0x8)
                /home/streampanel/go/pkg/mod/github.com/gorilla/websocket@v1.5.3/conn.go:480 +0x3a
        github.com/gorilla/websocket.(*Conn).NextWriter(0xc001e034a0, 0x8)
                /home/streampanel/go/pkg/mod/github.com/gorilla/websocket@v1.5.3/conn.go:520 +0x3f
        github.com/gorilla/websocket.(*Conn).WriteMessage(0x37d2cb0?, 0x1e5f71c?, {0xc000945490, 0x5, 0x5})
                /home/streampanel/go/pkg/mod/github.com/gorilla/websocket@v1.5.3/conn.go:773 +0x137
        github.com/andreykaipov/goobs.(*Client).Disconnect(0xc001c26fc0)
                /home/streampanel/go/pkg/mod/github.com/xaionaro-go/goobs@v0.0.0-20241009130652-ffb0e76ad260/client.go:123 +0xe5

The documentation of github.com/gorilla/websocket explicitly forbids concurrent writing and reading.
See section "Concurrency" in: https://pkg.go.dev/github.com/gorilla/websocket#hdr-Concurrency

@xaionaro xaionaro mentioned this pull request Oct 25, 2024
The bug:
	panic: concurrent write to websocket connection
	goroutine 66624 [running]:
	github.com/gorilla/websocket.(*messageWriter).flushFrame(0xc001ad7ef0, 0x1, {0x0?, 0x0?, 0x0?})
		/home/streampanel/go/pkg/mod/github.com/gorilla/websocket@v1.5.3/conn.go:617 +0x4b8
	github.com/gorilla/websocket.(*messageWriter).Close(0xc001e12f60?)
		/home/streampanel/go/pkg/mod/github.com/gorilla/websocket@v1.5.3/conn.go:731 +0x35
	github.com/gorilla/websocket.(*Conn).beginMessage(0xc001e034a0, 0xc001e12f60, 0x8)
		/home/streampanel/go/pkg/mod/github.com/gorilla/websocket@v1.5.3/conn.go:480 +0x3a
	github.com/gorilla/websocket.(*Conn).NextWriter(0xc001e034a0, 0x8)
		/home/streampanel/go/pkg/mod/github.com/gorilla/websocket@v1.5.3/conn.go:520 +0x3f
	github.com/gorilla/websocket.(*Conn).WriteMessage(0x37d2cb0?, 0x1e5f71c?, {0xc000945490, 0x5, 0x5})
		/home/streampanel/go/pkg/mod/github.com/gorilla/websocket@v1.5.3/conn.go:773 +0x137
	github.com/andreykaipov/goobs.(*Client).Disconnect(0xc001c26fc0)
		/home/streampanel/go/pkg/mod/github.com/xaionaro-go/goobs@v0.0.0-20241009130652-ffb0e76ad260/client.go:123 +0xe5

The documentation of github.com/gorilla/websocket explicitly forbids concurrent writing and reading.
See section "Concurrency" in:

	https://pkg.go.dev/github.com/gorilla/websocket#hdr-Concurrency
@xaionaro xaionaro force-pushed the bugfix/panic_concurrent_writing branch from e75f683 to 7bb4b24 Compare October 25, 2024 14:52
@andreykaipov andreykaipov merged commit 3c6c796 into andreykaipov:main Oct 25, 2024
8 checks passed
@andreykaipov andreykaipov added the bug Something isn't working label Oct 25, 2024
@Vany
Copy link

Vany commented Oct 27, 2024

no =) #182 is a different mem addr =)
this issue is about websocket handling and #182 is about data received =)

@xaionaro
Copy link
Contributor Author

no =) #182 is a different mem addr =) this issue is about websocket handling and #182 is about data received =)

Could you take a look at #179 ?

@xaionaro xaionaro deleted the bugfix/panic_concurrent_writing branch October 27, 2024 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants