Skip to content

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

Merged
nmetulev merged 18 commits intomainfrom
leilzh/crash
Apr 10, 2026
Merged

feat: Add crash dump capture and analysis to --debug-output#414
nmetulev merged 18 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

  • Managed (.NET) crashes → analyzed with Microsoft.Diagnostics.Runtime (ClrMD). No symbols needed, results are instant.
  • Native (C++/WinRT) crashes → analyzed with system32\dbgeng.dll. Works without symbols (shows Module+offset), but adding --symbols downloads PDBs from Microsoft Symbol Server for full function names.

Flow:

App crashes → Write dump → ClrMD analysis → Found managed exception?
→ Yes: Show exception type, message, managed stack trace
→ No: Fall back to DbgEng native analysis (with or without symbols)
→ Terminal shows summary, full details in log file

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 crash dump capture and automated analysis during app execution with the --debug-output flag. When a WinUI 3 app crashes, the tool now automatically writes a minidump and performs a managed or native analysis without needing external tools. Users can enrich native crash analysis by adding the --symbols flag to download PDBs for better diagnostics.

Usage example:

winapp run  --debug-output --symbols

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.42 MB 📈 +1.20 MB (+4.10%)
CLI (x64) 29.67 MB 30.79 MB 📈 +1.12 MB (+3.78%)
MSIX (ARM64) 12.32 MB 12.84 MB 📈 +533.0 KB (+4.23%)
MSIX (x64) 13.10 MB 13.63 MB 📈 +543.4 KB (+4.05%)
NPM Package 25.63 MB 26.70 MB 📈 +1.08 MB (+4.19%)
NuGet Package 25.71 MB 26.79 MB 📈 +1.08 MB (+4.22%)

Test Results

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

Test Coverage

20.6% line coverage, 35.8% branch coverage · ⚠️ -0.4% vs. baseline

CLI Startup Time

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


Updated 2026-04-10 00:02:10 UTC · commit c9163b0 · 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.

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 39 out of 60 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

src/winapp-CLI/WinApp.Cli/Commands/RunCommand.cs:136

  • --symbols is described as “only used with --debug-output”, but there’s no validation preventing users from passing --symbols without --debug-output (it will be silently ignored). Add an explicit check (useSymbols && !debugOutput) to return an error, or hide the option unless --debug-output is set.

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

nmetulev and others added 4 commits April 9, 2026 15:42
…g noise

- Add PdbSourceResolver to CrashDumpService that reads portable PDBs using
  System.Reflection.Metadata to map ClrMD stack frames to source file:line
- Thread symbolSearchPaths (build output folder) through IDebugOutputService
  and ICrashDumpService interfaces so PDBs are found without copying
- Apply source resolution to exception stacks, stack overflow detection,
  and all-threads detail log
- Filter OutputDebugString console output to suppress OS/framework noise
  (WinUI, COM, DirectX, kernel traces) while logging everything to file
- Filter first-chance exceptions on console to only show CLR, AV, and SOE
  while logging all exception codes to the debug log file

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… resolution

- Show tip to re-run with --symbols when a native crash occurs without it
- Update debugging.md and usage.md to document source file:line resolution
  from PDBs and console noise filtering behavior
- Add --symbols usage example to usage.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…HANDLE for dump capture

- Thread useSymbols parameter into LaunchViaExecutionAliasAsync so
  --symbols is not silently ignored when combined with --with-alias
- Add PROCESS_DUP_HANDLE access right to OpenProcess call in
  WriteMiniDump, required by MiniDumpWithHandleData dump type

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…f stack trace

When winapp (ARM64) debugs an x64 app under emulation, ClrMD cannot
load the cross-architecture DAC DLL. Detect the architecture mismatch
early and display a clean message pointing the user to WinDbg, instead
of dumping an internal ClrDiagnosticsException stack trace.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Display debug log path when app exits normally (no crash), so users
  can find captured OutputDebugString messages and first-chance exceptions
- Remove unused threadId parameter from WriteMiniDump — it was accepted
  but never used, misleading callers about its purpose

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nmetulev nmetulev merged commit f485361 into main Apr 10, 2026
12 checks passed
@nmetulev nmetulev deleted the leilzh/crash branch April 10, 2026 00:36
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.

3 participants