Skip to content

#6172 Crash on recordResultCode - #6173

Merged
akleshchev merged 1 commit into
developfrom
andreyk/viewer_6172
Aug 24, 2026
Merged

#6172 Crash on recordResultCode#6173
akleshchev merged 1 commit into
developfrom
andreyk/viewer_6172

Conversation

@akleshchev

Copy link
Copy Markdown
Contributor

mResutCodes gets modified from different threads, mutex it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a crash in HTTPStats::recordResultCode() by adding mutual exclusion around the shared result-code map, which is accessed from multiple threads in the HTTP subsystem.

Changes:

  • Added a mutex to protect access to the result-code statistics map.
  • Wrapped recordResultCode(), resetStats(), and dumpStats() result-code map access in std::lock_guard.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
indra/llcorehttp/httpstats.h Adds a mutex member and annotates recordResultCode() threading context.
indra/llcorehttp/httpstats.cpp Applies locking around result-code map mutation/iteration in reset/record/dump paths.
Suppressed comments (1)

indra/llcorehttp/httpstats.cpp:105

  • dumpStats() reads mDataUp/mDataDown/mRequests without synchronization while those can be updated from other threads. If using mResultCodesMutex to guard all stats updates, snapshot these values (and a copy of the result-code map) under the lock, then format output after releasing the lock to minimize blocking the HTTP thread.
    out << "Result Codes:" << std::endl << "--- -----" << std::endl;
    {
        std::lock_guard<std::mutex> lock(mResultCodesMutex);
        for (std::map<S32, S32>::iterator it = mResutCodes.begin(); it != mResutCodes.end(); ++it)
        {

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread indra/llcorehttp/httpstats.cpp Outdated
Comment on lines 44 to 48
{
std::lock_guard<std::mutex> lock(mResultCodesMutex);
mResutCodes.clear();
}
mDataDown.reset();
Comment on lines 56 to +60
}

void recordHTTPRequest() { ++mRequests; }

void recordResultCode(S32 code);
void recordResultCode(S32 code); // http thread

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I focused on recordResultCode, since it's the only one called by stageAfterCompletion, but in this case it's cheap to cover more.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

indra/llcorehttp/httpstats.h:62

  • recordHTTPRequest() increments mRequests without holding mStatsMutex, while resetStats()/dumpStats() now access mRequests under that mutex. This leaves a remaining data race (and can still crash/produce corrupted stats) when HttpRequest objects are created concurrently with resetStats()/dumpStats(). Guard the increment with the same mutex (or make mRequests atomic and adjust callers accordingly).
        void    recordHTTPRequest() { ++mRequests; }

        void    recordResultCode(S32 code); // http thread

mResutCodes gets modified from different threads, mutex it.
@akleshchev
akleshchev force-pushed the andreyk/viewer_6172 branch from c478ae8 to 66f7aab Compare August 24, 2026 15:00
@akleshchev
akleshchev merged commit 0da3853 into develop Aug 24, 2026
19 checks passed
@akleshchev
akleshchev deleted the andreyk/viewer_6172 branch August 24, 2026 17:09
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 24, 2026
@akleshchev akleshchev linked an issue Aug 25, 2026 that may be closed by this pull request
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BugSplat: HTTPStats::recordResultCode

3 participants