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

WebSocket: fix bad assert, unstick shutdown #10366

Closed
wants to merge 4 commits into from

Conversation

bagder
Copy link
Member

@bagder bagder commented Jan 30, 2023

No description provided.

Reported-by: Stanley Wucw
Fixes #10347
As this mode uses blocking sockets, it must set them back to
non-blocking in disconnect to avoid the risk of getting stuck.
@bagder bagder closed this in 0975449 Jan 30, 2023
bagder added a commit that referenced this pull request Jan 30, 2023
As this mode uses blocking sockets, it must set them back to
non-blocking in disconnect to avoid the risk of getting stuck.

Closes #10366
@bagder bagder deleted the bagder/ws-assert-shutdown branch January 30, 2023 14:39
@@ -479,7 +479,6 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer,

/* update buffer and frame info */
wsp->frame.offset += datalen;
DEBUGASSERT(wsp->frame.bytesleft >= (curl_off_t)datalen);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this assert is bad by itself, as long as the following two lines is there. The assert protects bytesleft from ever going negative in the subtraction two lines down. With the assert gone, it's possible for bytesleft to go negative which I don't think is the intention but shows that the assumptions are wrong somewhere else.

Copy link
Member Author

@bagder bagder Jan 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this reproducer case, bytelength was zero at this point, so the assert() was clearly not doing a good job at that position at least. But sure, maybe it would work better in the conditional block just before the subtraction is done.

We can always add more asserts when we go about and continue to debug this functionality.

bch pushed a commit to bch/curl that referenced this pull request Jul 19, 2023
Reported-by: Stanley Wucw
Fixes curl#10347
Closes curl#10366
bch pushed a commit to bch/curl that referenced this pull request Jul 19, 2023
As this mode uses blocking sockets, it must set them back to
non-blocking in disconnect to avoid the risk of getting stuck.

Closes curl#10366
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants