fix(debug): Print stack trace for unhandled win32 exceptions to debug log#1424
Merged
xezon merged 6 commits intoTheSuperHackers:mainfrom Aug 8, 2025
Merged
fix(debug): Print stack trace for unhandled win32 exceptions to debug log#1424xezon merged 6 commits intoTheSuperHackers:mainfrom
xezon merged 6 commits intoTheSuperHackers:mainfrom
Conversation
slurmlord
commented
Aug 5, 2025
| g_LastErrorDump.concat("\n"); | ||
| } | ||
| callback(line); | ||
| callback("\n"); |
Author
There was a problem hiding this comment.
The callback is basically DEBUG_LOG, so due to the recent newline changes there, this newline is no longer needed.
OmniBlade
approved these changes
Aug 6, 2025
OmniBlade
left a comment
There was a problem hiding this comment.
Might want replicating to at least WorldBuilder to capture exception info there as well, but that can be handled at some later point.
fbraz3
pushed a commit
to fbraz3/GeneralsX
that referenced
this pull request
Nov 10, 2025
fbraz3
pushed a commit
to fbraz3/GeneralsX
that referenced
this pull request
Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This change adds a process-wide win32/se exception filter that is invoked when an unhandled exception occurs. This filter logs the stack trace of the exception to the debug log and lets the rest of the exception handling proceed, typically by terminating the process.
This filter does not get invoked when a debugger is attached to the process.
Background
The current implementation uses _set_se_translator to get a callback when an unhandled win32 exception occurs, such as an access violation. This callback is then used to log the stack trace for the exception to the debug log.
There are multiple problems with this as currently implemented:
Implementation
This change removes all calls to _set_se_translator from various threads, and replaces them with a call to SetUnhandledExceptionFilter from WinMain for Generals and ZH and CWorldBuilderApp::InitInstance for WorldBuilders. This is process-wide, and applies to all threads. The unhandled exception filter calls the existing DumpExceptionInfo method for logging the stack trace to the debug log, before returning a EXCEPTION_EXECUTE_HANDLER value indicating that the associated exception handler should be executed.
There are other calls to _set_se_translator in the code, but as far as I can tell they are used by the tools and not the game or WorldBuilder. They have been left as is, and since the call to SetUnhandledExceptionFilter is done in WinMain for the games and InitInstance for WorldBuilders it should not change the behavior of the other tools.
Validation
Using a VS2022 build, triggering an access violation, the current main version will crash with no mention of the exception in the debug log. After applying this change the process still crashes, but the stack trace for the access violation is logged before exiting.