Skip to content

fix: address three threading issues that could cause intermittent OOS#384

Open
andy5995 wants to merge 1 commit intodevelopfrom
investigate/threading-oos
Open

fix: address three threading issues that could cause intermittent OOS#384
andy5995 wants to merge 1 commit intodevelopfrom
investigate/threading-oos

Conversation

@andy5995
Copy link
Copy Markdown
Collaborator

  1. Replace piecemeal pendingCommands access with atomic takePendingCommands() snapshot, guarded by pendingCommandsMutex (shared with the client's networkCommandListThreadAccessor), eliminating a TOCTOU race between the network receive thread and the game-loop thread.

  2. Replace static-local alreadyInLagCheck with a ServerInterface member variable inLagCheck, so the reentrancy guard is per-instance and is properly reset on construction.

  3. Wrap the requestedCommands drain loop in updateKeyframe() with serverSynchAccessor, which already guards requestCommand() writes. Overflow count is captured inside the lock and the warning broadcast is sent after releasing it to avoid potential deadlock.

1. Replace piecemeal pendingCommands access with atomic takePendingCommands()
   snapshot, guarded by pendingCommandsMutex (shared with the client's
   networkCommandListThreadAccessor), eliminating a TOCTOU race between the
   network receive thread and the game-loop thread.

2. Replace static-local alreadyInLagCheck with a ServerInterface member
   variable inLagCheck, so the reentrancy guard is per-instance and is
   properly reset on construction.

3. Wrap the requestedCommands drain loop in updateKeyframe() with
   serverSynchAccessor, which already guards requestCommand() writes.
   Overflow count is captured inside the lock and the warning broadcast
   is sent after releasing it to avoid potential deadlock.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@andy5995 andy5995 force-pushed the investigate/threading-oos branch from db831f3 to d43873f Compare March 25, 2026 10:55
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