Skip to content

Fix mutex crash on app exit (fixes #89)#158

Merged
erikdarlingdata merged 1 commit intodevfrom
feature/fix-mutex-crash
Feb 19, 2026
Merged

Fix mutex crash on app exit (fixes #89)#158
erikdarlingdata merged 1 commit intodevfrom
feature/fix-mutex-crash

Conversation

@erikdarlingdata
Copy link
Owner

Summary

  • ReleaseMutex() in OnExit throws ApplicationException when called by a thread that doesn't own the mutex
  • Tracked via _ownsMutex field — only release if we actually acquired ownership
  • Fixed in both Dashboard and Lite

Root Cause

When the app detects a second instance, it creates the mutex but doesn't own it, then calls Shutdown(). During OnExit, ReleaseMutex() throws because the calling thread isn't the owner. This is an unhandled exception during shutdown, so it terminates the process.

Credit to @jaglick for the stack trace on #89.

Test plan

  • Both projects build clean (0 errors, 0 warnings)
  • Dashboard and Lite launch and run normally
  • Verify second-instance launch no longer crashes on exit

ReleaseMutex() throws ApplicationException if called by a thread
that doesn't own the mutex. This happens when the app exits after
detecting a second instance, or when shutdown is triggered from a
non-owning thread. Track ownership and only release if we own it.

Fixed in both Dashboard and Lite.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 440fab9 into dev Feb 19, 2026
@erikdarlingdata erikdarlingdata deleted the feature/fix-mutex-crash branch February 20, 2026 13:20
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