Skip to content

Fix games.status deadlock by eliminating double checkGameStatus call#55

Merged
pardeike merged 3 commits intomainfrom
copilot/fix-1702f379-c975-4704-9078-e3c90fc7bb54
Sep 17, 2025
Merged

Fix games.status deadlock by eliminating double checkGameStatus call#55
pardeike merged 3 commits intomainfrom
copilot/fix-1702f379-c975-4704-9078-e3c90fc7bb54

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 17, 2025

Fixes the issue where gabs.games_status({"gameId":"rimworld"}) would hang indefinitely due to a mutex deadlock.

Problem

The games.status tool was calling checkGameStatus() twice within the same execution path:

  1. First call: getStatusDescription(game.ID, game) internally calls checkGameStatus() to get the status
  2. Second call: Direct call to checkGameStatus(game.ID) for launcher-specific warning logic

Since checkGameStatus() acquires a mutex (s.mu.Lock()), this double acquisition could cause a deadlock under certain conditions, particularly with Steam/Epic launcher games like RimWorld.

Solution

  • Modified the games.status tool to call checkGameStatus() only once and reuse the result
  • Added new helper function getStatusDescriptionFromStatus() that accepts the status as a parameter instead of calling checkGameStatus() again
  • Maintained backward compatibility by keeping the original getStatusDescription() function for other parts of the codebase

Code Changes

The fix eliminates the duplicate mutex acquisition while preserving all existing functionality:

// Before: Double checkGameStatus() call
statusDesc := s.getStatusDescription(game.ID, game)  // calls checkGameStatus()
// ...
status := s.checkGameStatus(game.ID)  // calls checkGameStatus() again!

// After: Single checkGameStatus() call
status := s.checkGameStatus(game.ID)  // call once
statusDesc := s.getStatusDescriptionFromStatus(status, game)  // reuse result

Testing

  • All existing tests continue to pass
  • Added specific test TestDoubleCheckGameStatusFix that validates the RimWorld scenario
  • Verified no behavioral changes for end users

This is a minimal, surgical fix that resolves the deadlock without any breaking changes.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits September 17, 2025 00:34
Co-authored-by: pardeike <853584+pardeike@users.noreply.github.com>
Co-authored-by: pardeike <853584+pardeike@users.noreply.github.com>
Copilot AI changed the title [WIP] Starting and stopping works but gabs.games_status({"gameId":"rimworld"}) still hangs Fix games.status deadlock by eliminating double checkGameStatus call Sep 17, 2025
Copilot AI requested a review from pardeike September 17, 2025 00:38
@pardeike pardeike marked this pull request as ready for review September 17, 2025 00:38
@pardeike pardeike merged commit eaf73ac into main Sep 17, 2025
4 checks passed
@pardeike pardeike deleted the copilot/fix-1702f379-c975-4704-9078-e3c90fc7bb54 branch September 17, 2025 00:38
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.

2 participants