Skip to content

feat(crashpad): capture handler logs (+ client stderr)#1658

Merged
jpnurmi merged 1 commit into
masterfrom
jpnurmi/feat/crashpad-log-file
Apr 23, 2026
Merged

feat(crashpad): capture handler logs (+ client stderr)#1658
jpnurmi merged 1 commit into
masterfrom
jpnurmi/feat/crashpad-log-file

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

Capture crashpad_handler's log output in the run directory: <run>/crashpad-handler.log. The log file is automatically cleaned up with the rest of the .run directory on the next sentry_init, so it doesn't bloat the database. When debug is enabled, forward the SDK's log level via --log-level=N so the file matches the configured verbosity. TRACE and DEBUG map to mini_chromium's LOG_VERBOSE, FATAL to LOG_FATAL, the rest 1:1.

As a side bonus, client-side logs are also routed to stderr when debug is enabled — previously only POSIX routed non-ERROR levels there by default.

Example:

>type .sentry-native\503a7424-7c3f-4644-755a-4b2d0469dbc4.run\crashpad-handler.log
[18468:19016:20260417,172034.322:ERROR filesystem_win.cc:115] GetFileAttributes C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\Desktop_Qt_6_9_1_MSVC2022_64bit-RelWithDebInfo\.sentry-native\attachments\3d5e3570-9cbd-4f6f-40f5-1bdd786d7254\__sentry-event: The system cannot find the file specified. (2)
[18468:19016:20260417,172034.323:ERROR filesystem_win.cc:115] GetFileAttributes C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\Desktop_Qt_6_9_1_MSVC2022_64bit-RelWithDebInfo\.sentry-native\attachments\3d5e3570-9cbd-4f6f-40f5-1bdd786d7254\__sentry-breadcrumb1: The system cannot find the file specified. (2)
[18468:19016:20260417,172034.324:ERROR filesystem_win.cc:115] GetFileAttributes C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\Desktop_Qt_6_9_1_MSVC2022_64bit-RelWithDebInfo\.sentry-native\attachments\3d5e3570-9cbd-4f6f-40f5-1bdd786d7254\__sentry-breadcrumb2: The system cannot find the file specified. (2)
[18468:19016:20260417,172034.377:ERROR filesystem_win.cc:115] GetFileAttributes C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\Desktop_Qt_6_9_1_MSVC2022_64bit-RelWithDebInfo\.sentry-native\attachments\3d5e3570-9cbd-4f6f-40f5-1bdd786d7254\screenshot.png: The system cannot find the file specified. (2)

See also:

Close: #1468

@github-actions

github-actions Bot commented Apr 17, 2026

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against ce0b2da

@jpnurmi jpnurmi force-pushed the jpnurmi/feat/crashpad-log-file branch from 5a1e927 to c9d0e55 Compare April 17, 2026 07:46
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/crashpad-log-file branch from fe3e4d2 to bb9e626 Compare April 17, 2026 11:21
@jpnurmi jpnurmi changed the title feat(crashpad): capture handler log output to <run>/crashpad.log feat(crashpad): capture client & handler logs Apr 17, 2026
@jpnurmi

jpnurmi commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator Author

@JoshuaMoelans What do you think about <run>/crashpad-handler.log for the handler side, and then either STDERR and/or <run>/crashpad-client.log for the client side. We can pass LOG_TO_STDERR to the client, but then crashpad-client.log becomes kind of redundant.

P.S. Neither of them barely logs almost anything at all. They seem to be mostly errors only.

@JoshuaMoelans

Copy link
Copy Markdown
Member

@jpnurmi yeah that sounds good, it's where I would expect these logs to show up (crashpad being a different process, I also don't mind it not going to STDERR by default either)

@jpnurmi

jpnurmi commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator Author

@JoshuaMoelans What about the client side that lives in the same process? It can also print useful errors, such as crashpad_handler missing +x on Linux. Here's a fabricated error with crashpad_handler.exe replaced by an empty file:

We can either capture client-side errors into STDERR so that it gets mixed in the sentry output (notice one message from crashpad_client_win.cc in the middle):

[sentry] INFO using database path "C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\.sentry-native"
[sentry] DEBUG starting transport
[sentry] DEBUG starting background worker thread
[sentry] DEBUG submitting 100 ms delayed task to background worker thread
[sentry] DEBUG starting backend
[sentry] DEBUG background worker thread started
[sentry] DEBUG starting crashpad backend with handler "C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\crashpad_handler.exe"
[sentry] DEBUG using minidump URL "https://127.0.0.1:12345/api/1/minidump/?sentry_client=sentry.native/0.13.7&sentry_key=aaa"
[19168:9228:20260420,170017.136:ERROR crashpad_client_win.cc:615] CreateProcess: %1 is not a valid Win32 application. (193)
[sentry] DEBUG registering crashpad WER handler "C:\Users\jpnurmi\Projects\sentry\sentry-playground\build\crashpad_wer.dll"
[sentry] WARN failed to start crashpad client handler
[sentry] WARN failed to initialize backend
[sentry] WARN `sentry_init` failed

Alternatively, we can capture it to <run>/crashpad-client.log:

C:\Users\jpnurmi\Projects\sentry\sentry-playground>type build\.sentry-native\c6a43bc8-2629-492d-e79c-94cb114aff09.run\crashpad-client.log
[19168:9228:20260420,170017.136:ERROR crashpad_client_win.cc:615] CreateProcess: %1 is not a valid Win32 application. (193)

Or, we can combine both so that you get crashpad-client.log and crashpad-handler.log side by side, even if the client-side logs appear in STDERR.

@JoshuaMoelans

Copy link
Copy Markdown
Member

@jpnurmi ah, in that case I think having it as part of the actual debug logs next to the Sentry ones could be helpful when debugging user's issues, since we usually have them send us the debug log outputs (and then having to look through the log file and the console output seems like a bit of double work). I think I misunderstood the client log side of things at first 😅 piping to STDERR sounds good to me!

@jpnurmi jpnurmi marked this pull request as ready for review April 21, 2026 11:04
@jpnurmi jpnurmi changed the title feat(crashpad): capture client & handler logs feat(crashpad): capture client stderr & handler logs Apr 21, 2026
@jpnurmi jpnurmi changed the title feat(crashpad): capture client stderr & handler logs feat(crashpad): capture handler logs (+ client stderr) Apr 21, 2026
Comment thread src/backends/sentry_backend_crashpad.cpp Outdated

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1077743. Configure here.

Comment thread src/backends/sentry_backend_crashpad.cpp
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/crashpad-log-file branch 2 times, most recently from 53a695e to 3d8e4e4 Compare April 21, 2026 13:20
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/crashpad-log-file branch from 3d8e4e4 to 0ed34e1 Compare April 21, 2026 14:22
Pass `--log-file=<run>/crashpad.log` to crashpad_handler so its log
output is written to the run directory alongside other session files.
The log is cleaned up with the rest of the `.run` directory on the
next `sentry_init`, so it doesn't bloat the database.

When `debug` is enabled, also forward the SDK's log level via
`--log-level=N` so the handler's log file matches the configured
verbosity (otherwise crashpad stays at its built-in default). TRACE
and DEBUG map to mini_chromium's `LOG_VERBOSE`, FATAL to `LOG_FATAL`,
the rest 1:1.

Closes #1468

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/crashpad-log-file branch from 0ed34e1 to ce0b2da Compare April 21, 2026 14:25
@jpnurmi jpnurmi merged commit a7c29b1 into master Apr 23, 2026
96 of 97 checks passed
@jpnurmi jpnurmi deleted the jpnurmi/feat/crashpad-log-file branch April 23, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crashpad: improve logging for debugging purposes

3 participants