fix(windows): the launcher is not marked CET compatible, so an overlay's DLL in it cannot make Windows end it with no log #229

Merged
HumanBean merged 1 commit from HumanBean/LongshotLauncher:fix/cet-compat-off into main 2026-11-21 19:14:56 +00:00
Owner

The launcher can be closed outright by Windows, with no log and no message, when an overlay or capture tool's DLL inside it trips the hardware stack protection (CET) that .NET 10 turns on for every program by default. #116's crash dump shows exactly that, and #152's start-up abort with "Unknown Hard Error" and no logs may be the same thing.

Summary

  • App/LongshotLauncher.csproj: <CETCompat>false</CETCompat>. Since .NET 9 the SDK marks the program CET compatible by default. With that mark on a CPU that has shadow stacks (both reporters have Zen 3: a 5600X and a 5800X), Windows fast-fails the process (FAST_FAIL_SET_CONTEXT_DENIED, 0xC0000409 subcode 0x30) when code inside it sets a thread's context outside the shadow stack while an exception unwinds. That is #116's stack: clr!IL_Throw, RaiseException, RtlUnwindEx, ProcessCLRException, RcContinueExit, with OBS's graphics-hook64.dll and NVIDIA's nvspcap64.dll loaded. The process dies before the UnhandledException handler (#171) can write anything, so the log has nothing. With the mark off, the exception unwinds normally: either it is caught, or the existing crash log records it.
  • tests/test_launcher_core.py: check_cet_compat_off reads the csproj, so the setting can't be dropped without the tests failing.

Not claimed: that this fixes #152. Its reporter ran rc.9, which predates the start-up crash log (#171, in rc.10), and an early Windows 10 21H1 build (19043.928) on a CET-capable CPU fits the same cause, but there is no dump to confirm it. If it still happens on a build with this change, the crash log from #171 should now have the exception.

Refs #116
Refs #152

Testing

  • Published the Windows single-file program from Linux the way scripts/package.sh does (-r win-x64 --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true), with clean obj/, and read the PE's extended DLL characteristics (debug directory entry type 20):
    • main: 0x1 (CET_COMPAT), inherited from the .NET 10 singlefilehost.exe
    • this branch: 0x0
  • python -I tests/test_launcher_core.py: passes (2599 checks).
  • LAUNCHER=$PWD python -I ../Tooling/tests/test_release.py: 3 failures (test_the_bump, test_the_next_stable, test_check_tag_against_the_published_releases). Unchanged main fails the same 3, and this change touches nothing release.py reads.
  • Not run on Windows: this is a Linux PC, so the crash itself has not been reproduced or confirmed fixed.

🤖 Generated with Claude Code

The launcher can be closed outright by Windows, with no log and no message, when an overlay or capture tool's DLL inside it trips the hardware stack protection (CET) that .NET 10 turns on for every program by default. #116's crash dump shows exactly that, and #152's start-up abort with "Unknown Hard Error" and no logs may be the same thing. ## Summary - `App/LongshotLauncher.csproj`: `<CETCompat>false</CETCompat>`. Since .NET 9 the SDK marks the program CET compatible by default. With that mark on a CPU that has shadow stacks (both reporters have Zen 3: a 5600X and a 5800X), Windows fast-fails the process (`FAST_FAIL_SET_CONTEXT_DENIED`, `0xC0000409` subcode `0x30`) when code inside it sets a thread's context outside the shadow stack while an exception unwinds. That is #116's stack: `clr!IL_Throw`, `RaiseException`, `RtlUnwindEx`, `ProcessCLRException`, `RcContinueExit`, with OBS's `graphics-hook64.dll` and NVIDIA's `nvspcap64.dll` loaded. The process dies before the `UnhandledException` handler (#171) can write anything, so the log has nothing. With the mark off, the exception unwinds normally: either it is caught, or the existing crash log records it. - `tests/test_launcher_core.py`: `check_cet_compat_off` reads the csproj, so the setting can't be dropped without the tests failing. Not claimed: that this fixes #152. Its reporter ran rc.9, which predates the start-up crash log (#171, in rc.10), and an early Windows 10 21H1 build (19043.928) on a CET-capable CPU fits the same cause, but there is no dump to confirm it. If it still happens on a build with this change, the crash log from #171 should now have the exception. Refs #116 Refs #152 ## Testing - Published the Windows single-file program from Linux the way `scripts/package.sh` does (`-r win-x64 --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true`), with clean `obj/`, and read the PE's extended DLL characteristics (debug directory entry type 20): - main: `0x1` (`CET_COMPAT`), inherited from the .NET 10 `singlefilehost.exe` - this branch: `0x0` - `python -I tests/test_launcher_core.py`: passes (2599 checks). - `LAUNCHER=$PWD python -I ../Tooling/tests/test_release.py`: 3 failures (`test_the_bump`, `test_the_next_stable`, `test_check_tag_against_the_published_releases`). Unchanged main fails the same 3, and this change touches nothing `release.py` reads. - Not run on Windows: this is a Linux PC, so the crash itself has not been reproduced or confirmed fixed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(windows): the launcher is not marked CET compatible, so an overlay's DLL in it cannot make Windows end it with no log
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 16s
0ed9a28482
.NET 9 and later mark a program compatible with Windows' hardware-enforced
stack protection (CET) by default. With it on, Windows fast-fails the process
(FAST_FAIL_SET_CONTEXT_DENIED, 0xC0000409 subcode 0x30) when a DLL injected
into it, such as an overlay or a capture tool, sets a thread's context outside
the shadow stack while an exception unwinds: the launcher closes with no log
and no message. <CETCompat>false</CETCompat> clears the flag on the published
single-file program; a check in tests/test_launcher_core.py keeps it.

Refs #116
Refs #152

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean deleted branch fix/cet-compat-off 2026-11-21 19:14:57 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/LongshotLauncher!229
No description provided.