Skip to content

bugfix(debug): Skip system-modal crash dialogs in headless runs - #3030

Merged
xezon merged 1 commit into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/headless-crash-dialogs
Jul 31, 2026
Merged

bugfix(debug): Skip system-modal crash dialogs in headless runs#3030
xezon merged 1 commit into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/headless-crash-dialogs

Conversation

@bobtista

@bobtista bobtista commented Jul 30, 2026

Copy link
Copy Markdown

ReleaseCrash and ReleaseCrashLocalized call MessageBox even when the game runs with -headless. The system-modal dialog blocks _exit(1), leaving an unattended process alive until somebody dismisses it.

Now only the dialog calls are skipped when TheGlobalData->m_headless is set. Crash reporting, minidump generation, and _exit(1) remain unchanged.

Todo:

  • Confirm -headless is parsed before subsystem initialization failures
  • Verify a -headless initialization failure exits 1, writes ReleaseCrashInfo.txt, and shows no UI
  • Verify the same failure without -headless retains the existing dialog
  • Verify a successful -headless run remains unaffected
  • Replicate to Generals — N/A, it's in Core

Verification (Windows, MSVC x86)

Built z_generals in both win32-debug (RTS_DEBUG) and win32 Release so both sides of the #if defined(RTS_DEBUG) split are covered. A subsystem initialization failure was induced by putting an invalid Bool (UseTrees = Maybe) in the install's loose Data\INI\GameData.ini, which makes INI::scanBool throw, gets rethrown as INIException, and lands in GameEngine::init's catch (INIException) handler.

Case Debug Release
Headless failure exit 1, ReleaseCrashInfo.txt written, no window exit 1, ReleaseCrashInfo.txt written, no window
Same failure without -headless "Technical Difficulties..." dialog shown, exit 1 after OK "Technical Difficulties..." dialog shown, exit 1 after OK
Successful headless run (-replay ... -headless) exit 0 exit 0

Pre-fix control: reverting Debug.cpp and rebuilding reproduces #3029 — the headless process stays alive on a visible system-modal dialog with no game window, and only exits once the dialog is dismissed by hand.

-headless is parsed by parseCommandLineForStartup in WinMain before GameMain, so m_headless is already set when GameEngine::init loads INI data.

Note on TheGlobalData == nullptr

ReleaseCrash already returns early when TheGlobalData is null, before reaching either MessageBox, so crashes that early show no dialog at all today. The null check in the new guards is therefore only meaningful in ReleaseCrashLocalized, where the dialog precedes the first TheGlobalData dereference. It is kept in all three for consistency.

@bobtista bobtista self-assigned this Jul 30, 2026
@bobtista bobtista added the Bug Something is not working right, typically is user facing label Jul 30, 2026
@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown

Greptile Summary

This PR prevents crash dialogs from blocking unattended headless runs.

  • Guards debug and release ReleaseCrash message boxes with the existing headless flag.
  • Applies the same guard to the localized crash dialog.
  • Leaves crash logging, minidump generation, and process termination unchanged.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
Core/GameEngine/Source/Common/System/Debug.cpp Adds headless-mode guards around all system-modal crash dialogs without altering crash-reporting or termination paths.

Reviews (2): Last reviewed commit: "bugfix(system): Skip system-modal crash ..." | Re-trigger Greptile

Comment thread Core/GameEngine/Source/Common/System/Debug.cpp Outdated
@xezon xezon added Debug Is mostly debug functionality Minor Severity: Minor < Major < Critical < Blocker ThisProject The issue was introduced by this project, or this task is specific to this project labels Jul 31, 2026

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code correct

@bobtista
bobtista force-pushed the bobtista/bugfix/headless-crash-dialogs branch from b69a40d to 5097c1b Compare July 31, 2026 19:25
@xezon xezon changed the title bugfix(system): Skip system-modal crash dialogs in headless runs bugfix(debug): Skip system-modal crash dialogs in headless runs Jul 31, 2026
@xezon
xezon merged commit 71d40c0 into TheSuperHackers:main Jul 31, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Debug Is mostly debug functionality Minor Severity: Minor < Major < Critical < Blocker ThisProject The issue was introduced by this project, or this task is specific to this project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Headless runs block on system-modal dialogs after fatal errors

2 participants