HCCleanupAsync deadlock on HCWebSocketConnectAsync failure.

Open
#909 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp
Domain
networking

Research direction

Start by reproducing the HCWebSocketConnectAsync 401 failure on XBOX GDK 250402, then trace HCCleanupAsync through the WebSocket cleanup path. Inspect WinHttpConnection::StartWinHttpClose and the WinHttpCloseHandle failure shown in the logs. Done means cleanup completes without deadlocking after the failed connection.

Written by the indexing model from the issue text.

Description

On XBOX GDK 250402 version after HCWebSocketConnectAsync failure(401 error code from http), the HCCleanupAsync creates deadlock and cannot be finished or even terminated. Possible reason that I found in logs is :

[0758][I][16:01:09.365][HTTPCLIENT] WinHttpConnection WinHttp callback statusCode=11
[0758][I][16:01:09.417][HTTPCLIENT] WinHttpConnection WinHttp callback statusCode=21
[0758][I][16:01:09.418][HTTPCLIENT] WinHttpConnection WinHttp callback statusCode=41
[0758][I][16:01:09.421][HTTPCLIENT] WinHttpConnection WinHttp callback statusCode=81
[0758][I][16:01:09.525][HTTPCLIENT] WinHttpConnection WinHttp callback statusCode=321
[0758][I][16:01:09.551][HTTPCLIENT] HCHttpCallPerform [ID 2] [TID 1880l] WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE
[0758][I][16:01:09.551][HTTPCLIENT] WinHttpConnection WinHttp callback statusCode=641
[0758][I][16:01:09.551][HTTPCLIENT] WinHttpConnection WinHttp callback statusCode=1281
[0758][I][16:01:09.551][HTTPCLIENT] HCHttpCallPerform [ID 2] [TID 1880l] Websocket WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE
[0758][E][16:01:09.551][HTTPCLIENT] HCHttpCallPerform [ID 2] [TID 1880l] WinHttpWebSocketCompleteUpgrade errorcode 4317
[0758][I][16:01:09.551][HTTPCLIENT] HCHttpCallResponseSetErrorCode [ID 2]: errorCode=80004005 (800710DD)
[0758][V][16:01:09.551][HTTPCLIENT] WinHttpConnection::StartWinHttpClose, current state=0 transitioning to ConnectionState::WinHttpClosing
[0758][E][16:01:09.551][HTTPCLIENT] WinHttpCloseHandle failed with errorCode=6
[0730][I][16:01:11.418][WEBSOCKET] HC_WEBSOCKET_OBSERVER::~HC_WEBSOCKET_OBSERVER

WinHttpCloseHandle couldn't be cleaned up, so it provokes deadlock.
Logs when I invoke HCCleanupAsync:

[071C][V][16:01:51.833][HTTPCLIENT] HC_PERFORM_ENV::Cleaning up, HTTP=0, WebSocket Connecting=0, WebSocket Connected=0
[071C][V][16:01:51.834][HTTPCLIENT] NetworkState::CleanupAsyncProvider::Begin: HTTP active=0, WebSocket Connecting=0, WebSocket Connected=0
[071C][V][16:01:55.382][HTTPCLIENT] CurlProvider::CleanupAsyncProvider, cleanupTasksRemaining=0
Dominant language
C++
Stars
295
Forks
144
Avg merge
2d 19h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/libHttpClient

All issues in microsoft/libHttpClient

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.