Skip to content

bugfix(threading): Ensure thread list critical section remains valid during CRT shutdown#483

Merged
x64-dev merged 1 commit intomainfrom
seer/bugfix/thread-list-cs-robustness
May 7, 2026
Merged

bugfix(threading): Ensure thread list critical section remains valid during CRT shutdown#483
x64-dev merged 1 commit intomainfrom
seer/bugfix/thread-list-cs-robustness

Conversation

@seer-by-sentry
Copy link
Copy Markdown

@seer-by-sentry seer-by-sentry Bot commented May 7, 2026

Fixes CLIENT-38C. The issue was that: Thread unregistration attempts to acquire a critical section lock whose underlying Windows handle is invalidated during application shutdown, causing an access violation.

  • Replaced the CriticalSectionClass used for ThreadList synchronization with a raw Windows CRITICAL_SECTION.
  • Allocated the CRITICAL_SECTION from the Windows process heap (GetProcessHeap) to guarantee its validity throughout the application's lifetime, even during CRT heap teardown.
  • Implemented thread-safe, one-time initialization for the critical section using InterlockedCompareExchangePointer.
  • Introduced ScopedThreadListLock as an RAII guard for the new raw CRITICAL_SECTION.
  • Updated thread registration/unregistration and main thread ID retrieval to use the new synchronization mechanism.

This fix was generated by Seer in Sentry, triggered by x64-dev. 👁️ Run ID: 13508812

Not quite right? Click here to continue debugging with Seer.

@seer-by-sentry seer-by-sentry Bot requested a review from x64-dev May 7, 2026 20:49
@x64-dev x64-dev marked this pull request as ready for review May 7, 2026 20:59
@x64-dev x64-dev merged commit bc32eb8 into main May 7, 2026
5 checks passed
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.

1 participant