Skip to content

Conversation

Eureak-zon
Copy link
Contributor

Description

This PR improves the crash handling mechanism on Windows platform to prevent applications from hanging in the background after crashes, which previously required manual termination through task manager.

Changes made:

  • Set Windows error mode using SetErrorMode() to suppress system error dialogs (SEM_NOGPFAULTERRORBOX, SEM_FAILCRITICALERRORS, SEM_NOOPENFILEERRORBOX)
  • Implement SetUnhandledExceptionFilter() with TerminateProcess() for immediate process termination
  • Ensure crashed processes exit cleanly without becoming zombie processes

Test Steps

  1. Build the application with the changes
  2. Trigger a crash (e.g., null pointer dereference)
  3. Verify that:
    • No Windows Error Reporting dialog appears
    • Process terminates immediately without hanging
    • No zombie processes remain in task manager
    • Application doesn't require manual termination

Before: Crashed applications would hang in background, requiring manual termination via task manager

After: Crashed applications terminate immediately and cleanly

Related Issue

This addresses the issue where crashed applications on Windows would remain as hanging processes that couldn't be terminated by task manager, requiring forced termination through system tools.

Problem: Program crashes but hangs in background instead of exiting cleanly
Solution: Direct process termination using Windows API without relying on potentially corrupted Qt event loops

- Replace std::terminate() with TerminateProcess() for immediate process termination
- Set Windows error mode to suppress system error dialogs
- Use SetUnhandledExceptionFilter to catch all unhandled exceptions
- Comment out AddVectoredExceptionHandler (keeping as reference)
- Ensure crashed processes exit cleanly without hanging in background

This resolves issues where crashed applications would remain as zombie
processes that couldn't be terminated by task manager.

Fixes: Program crashes but hangs in background instead of exiting
@HTRamsey
Copy link
Collaborator

HTRamsey commented Aug 14, 2025

Nice, was working on that here but just didn't get to finish. I'll probably add yours first then just move it to the new file I created in my PR

@Eureak-zon
Copy link
Contributor Author

@HTRamsey You can consider generating a dmp file when a crash occurs. I haven't figured out how to add this feature yet.

@Eureak-zon Eureak-zon marked this pull request as ready for review August 14, 2025 17:34
@HTRamsey
Copy link
Collaborator

I went ahead and merged my other PR that included this. If you want to make any changes to what I did please feel free

@HTRamsey HTRamsey closed this Aug 22, 2025
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