Skip to content

feat: Add crash dump capture and analysis to --debug-output#414

Open
lei9444 wants to merge 7 commits intomainfrom
leilzh/crash
Open

feat: Add crash dump capture and analysis to --debug-output#414
lei9444 wants to merge 7 commits intomainfrom
leilzh/crash

Conversation

@lei9444
Copy link
Copy Markdown
Contributor

@lei9444 lei9444 commented Apr 8, 2026

Description

When a WinUI 3 app crashes during winapp run --debug-output, the previous output only showed a bare exception code and address. This PR adds automatic crash dump capture and in-process analysis using ClrMD (Microsoft.Diagnostics.Runtime) — no external tools required.

How it works

  1. First-chance context capture — When a critical first-chance exception (Access Violation, Stack Overflow, CLR/C++ exception) fires, the faulting thread's CONTEXT is saved via GetThreadContext. At this point the context still points to user code — before WinUI's FailFastWithStowedExceptions replaces the stack.
  2. Crash dump on second-chance — On second-chance exception (actual crash), MiniDumpWriteDump is called with the saved first-chance context as MINIDUMP_EXCEPTION_INFORMATION, preserving the original crash location in the dump. For Stack Overflow (always fatal in .NET, no second-chance follows), the dump is captured immediately at first-chance.
  3. ClrMD analysis — The dump is analyzed in-process using Microsoft.Diagnostics.Runtime:
  • First checks thread.CurrentException for managed exceptions
  • Falls back to heap scanning for exceptions cleared by WinUI's FailFast
  • Detects Stack Overflow via deep recursion patterns (>100 repeated frames)
  1. No external dependencies — Unlike approaches based on CDB/WinDbg or procdump, this works out of the box with zero tool installation. For native-only crashes (no CLR runtime in dump), the dump path is printed with WinDbg instructions as fallback.

Output layering

Terminal: Crash summary: faulting symbol, module, source file:line, compact stack (framework frames collapsed)
Log file: All OutputDebugString messages, first-chance exceptions, full thread stacks with module names
Dump file: Full memory minidump for deep analysis with WinDbg or Visual Studio

Usage Example

winapp run <output-folder> --debug-output

Related Issue

Type of Change

  • ✨ New feature

Checklist

Screenshots / Demo

crash1

AI Description

This PR introduces automatic crash dump capture and analysis during winapp run --debug-output. When a WinUI 3 app encounters critical exceptions, a minidump is generated, and the crash is analyzed in-process using ClrMD, eliminating the need for external tools. Users can utilize it as follows:

winapp run  --debug-output

Breaking Change: None.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Base automatically changed from nmetulev/ui-command to main April 8, 2026 18:23
@github-actions github-actions bot added the enhancement New feature or request label Apr 9, 2026
@lei9444 lei9444 requested a review from Copilot April 9, 2026 03:34
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

Build Metrics Report

Binary Sizes

Artifact Baseline Current Delta
CLI (ARM64) 29.22 MB 30.34 MB 📈 +1.11 MB (+3.81%)
CLI (x64) 29.67 MB 30.71 MB 📈 +1.04 MB (+3.51%)
MSIX (ARM64) 12.32 MB 12.81 MB 📈 +501.8 KB (+3.98%)
MSIX (x64) 13.10 MB 13.59 MB 📈 +502.2 KB (+3.74%)
NPM Package 25.63 MB 26.63 MB 📈 +1022.6 KB (+3.90%)
NuGet Package 25.71 MB 26.71 MB 📈 +1.01 MB (+3.92%)

Test Results

718 passed out of 718 tests in 411.0s (+4 tests, -3.7s vs. baseline)

Test Coverage

20.8% line coverage, 36.5% branch coverage · ⚠️ -0.2% vs. baseline

CLI Startup Time

40ms median (x64, winapp --version) · ✅ no change vs. baseline


Updated 2026-04-09 05:06:00 UTC · commit ccd07b8 · workflow run

@lei9444 lei9444 changed the title feat: Add crash dump capture and CDB analysis to --debug-output feat: Add crash dump capture and analysis to --debug-output Apr 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 27 out of 35 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants