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

esp_websocket: fix a crash when network anomaly (IDFGH-13461) #629

Closed
wants to merge 2 commits into from

Conversation

shootao
Copy link

@shootao shootao commented Aug 14, 2024

when disconnect the wifi, the esp_websocket_client_task continue to called
esp_transport_poll_read to read, but the default the time is 1s, then the read had timeout will called esp_websocket_client_abort_connection to destory some handle, at this time, esp_websocket_client_send_with_exact_opcode still blocked.
when esp_websocket_client_send_with_exact_opcode had timeout, will trigger crash , because handle(erro handle) already release

@CLAassistant
Copy link

CLAassistant commented Aug 14, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ shootao
❌ xutao


xutao seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot changed the title esp_websocket: fix a crash when network anomaly esp_websocket: fix a crash when network anomaly (IDFGH-13461) Aug 14, 2024
Copy link
Collaborator

@david-cermak david-cermak left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

could you please click trough the CLA agreement so we can accept your contribution?

@david-cermak
Copy link
Collaborator

Thank you for the update! I noticed that there are now two commits from different authors, and the pre-commit test didn’t pass.

Could you please review our contribution guidelines and update this PR accordingly? Specifically, it would be great if you could:

  • Fix the commit messages
  • Squash the two commits into one
  • Rebase the branch (we recently resolved some CI issues on the master branch)

If you’d prefer, just let me know -- I can take care of the chores and push your work in a separate PR, while still crediting your original commit.

david-cermak pushed a commit to david-cermak/esp-protocols that referenced this pull request Oct 31, 2024
When WiFi disconnects, `esp_websocket_client_task` continues polling
`esp_transport_poll_read()` with a default 1-second timeout.
If a timeout triggers `esp_websocket_client_abort_connection`,
certain resources are released.
However, if `esp_websocket_client_send_with_exact_opcode`
is still blocked at this point, it will cause a crash
when it times out and accesses the released handle.
This fix prevents potential crashes by ensuring proper
synchronization between abort and send functions.

Merges: espressif#629
@david-cermak
Copy link
Collaborator

@shootao Thanks again for the fixes. will merge by means of #684

david-cermak pushed a commit to david-cermak/esp-protocols that referenced this pull request Oct 31, 2024
When WiFi disconnects, `esp_websocket_client_task` continues polling
`esp_transport_poll_read()` with a default 1-second timeout.
If a timeout triggers `esp_websocket_client_abort_connection`,
certain resources are released.
However, if `esp_websocket_client_send_with_exact_opcode`
is still blocked at this point, it will cause a crash
when it times out and accesses the released handle.
This fix prevents potential crashes by ensuring proper
synchronization between abort and send functions.

Merges: espressif#629
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.

5 participants