-
Notifications
You must be signed in to change notification settings - Fork 51
feat: external crash reporter #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@sentry review |
On it! We are reviewing the PR and will provide feedback shortly. |
PR DescriptionThis pull request introduces a mechanism to launch an external feedback handler after a crash has been processed. This allows for custom post-crash actions, such as gathering additional diagnostic information or notifying users about the crash. Click to see moreKey Technical Changes
Architecture DecisionsThe design uses a file-based approach for communication between the crash handler and the feedback handler. The crash handler creates a feedback envelope file containing crash data and attachments, and passes the path to this file as an argument to the feedback handler. This approach decouples the crash handler from the feedback handler, allowing for greater flexibility and extensibility. The Dependencies and InteractionsThis change depends on the Risk Considerations
Notable Implementation Details
|
Co-authored-by: seer-by-sentry[bot] <157164994+seer-by-sentry[bot]@users.noreply.github.com>
Co-authored-by: seer-by-sentry[bot] <157164994+seer-by-sentry[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes all sense.
We can think about enabling the upstream tests, given that we have added considerable changes to our crashpad fork that no longer maintain compatibility with upstream. Tests allow us to verify whether any of our changes affect (untouched) upstream behavior, and would further provide a basis for isolated unit tests, which is less effort for an envelope writer than going full circle via the consuming integration tests. However, it isn't necessary to include this in this PR. |
c5882b8
to
dbc4ea5
Compare
msgpack/msgpack-cxx looked nice at first because it's a header-only library, but then I noticed the size:
ludocode/mpack looks more reasonable:
What about the JSON library? Is nlohmann/json ok or should we look for something slimmer? |
clang++-19: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]
In general, I would love to cut down dependencies to an absolute minimum. If there is a way in which we can share between the Native SDK and the Even more important than source size is the effect on binary size. C++ code tends to grow binaries dramatically due to the combination of template instantiation, aggressive inlining, and dependencies on the standard library. So, even a slim-looking header-only "modern" C++ library can have severe consequences on binary size. The In addition to that - if it is modern C++ - it can also introduce problems for building and deployment since those libraries might depend on features that are not evenly supported by toolchains used downstream (this is a recurring pain and it applies on a finer-grained level than C++ standard version, because particular features of the standard are not bound to appear as implementations in the same toolchain version).
Concretely, to the above,
I wonder if we could somehow reuse the existing capabilities of the Native SDK here instead of introducing yet another full-featured JSON implementation, of which we only use a small portion. For instance, just thinking out loud: what if you embed MsgPack encoded files from the This way, you could eliminate the need to introduce all these details to the |
Sharing code between sentry-native and crashpad would be useful! I still remember well the duplicate screenshotting code. 😓 While I hesitated to make Crashpad aware of the |
Hmm, if we had IPC on macOS, we could pass breadcrumbs one by one instead of writing them into files... 🤔 |
Static Crashpad builds with MSVC 2022 ( masterjpnurmi@surface MINGW64 ~/Projects/sentry/sentry-native (master)
$ ls -lah build/master/RelWithDebInfo/
total 49M
drwxr-xr-x 1 jpnurmi 197610 0 Aug 13 10:49 ./
drwxr-xr-x 1 jpnurmi 197610 0 Aug 13 10:49 ../
-rwxr-xr-x 1 jpnurmi 197610 1.2M Aug 13 10:49 crashpad_handler.exe*
-rw-r--r-- 1 jpnurmi 197610 13M Aug 13 10:49 crashpad_handler.pdb
-rwxr-xr-x 1 jpnurmi 197610 38K Aug 13 10:47 crashpad_wer.dll*
-rw-r--r-- 1 jpnurmi 197610 604K Aug 13 10:47 crashpad_wer.pdb
-rw-r--r-- 1 jpnurmi 197610 42K Aug 13 10:49 minidump.dmp
-rw-r--r-- 1 jpnurmi 197610 2.4M Aug 13 10:49 sentry.lib
-rw-r--r-- 1 jpnurmi 197610 868K Aug 13 10:49 sentry.pdb
-rwxr-xr-x 1 jpnurmi 197610 812K Aug 13 10:49 sentry_example.exe*
-rw-r--r-- 1 jpnurmi 197610 6.8M Aug 13 10:49 sentry_example.pdb
-rwxr-xr-x 1 jpnurmi 197610 760K Aug 13 10:48 sentry_fuzz_json.exe*
-rw-r--r-- 1 jpnurmi 197610 6.9M Aug 13 10:48 sentry_fuzz_json.pdb
-rwxr-xr-x 1 jpnurmi 197610 806K Aug 13 10:49 sentry_screenshot.exe*
-rw-r--r-- 1 jpnurmi 197610 6.9M Aug 13 10:49 sentry_screenshot.pdb
-rwxr-xr-x 1 jpnurmi 197610 1.1M Aug 13 10:48 sentry_test_unit.exe*
-rw-r--r-- 1 jpnurmi 197610 7.5M Aug 13 10:48 sentry_test_unit.pdb
-rw-r--r-- 1 jpnurmi 197610 273 Aug 13 10:49 view-hierarchy.json feat/feedback-handlerjpnurmi@surface MINGW64 ~/Projects/sentry/sentry-native (feat/feedback-handler)
$ ls -lah build/feedback-handler/RelWithDebInfo/
total 84M
drwxr-xr-x 1 jpnurmi 197610 0 Aug 13 10:52 ./
drwxr-xr-x 1 jpnurmi 197610 0 Aug 13 10:52 ../
-rwxr-xr-x 1 jpnurmi 197610 1.6M Aug 13 10:52 crashpad_handler.exe*
-rw-r--r-- 1 jpnurmi 197610 17M Aug 13 10:52 crashpad_handler.pdb
-rwxr-xr-x 1 jpnurmi 197610 38K Aug 13 10:51 crashpad_wer.dll*
-rw-r--r-- 1 jpnurmi 197610 604K Aug 13 10:51 crashpad_wer.pdb
-rw-r--r-- 1 jpnurmi 197610 42K Aug 13 10:52 minidump.dmp
-rw-r--r-- 1 jpnurmi 197610 2.4M Aug 13 10:52 sentry.lib
-rw-r--r-- 1 jpnurmi 197610 868K Aug 13 10:52 sentry.pdb
-rwxr-xr-x 1 jpnurmi 197610 1.1M Aug 13 10:52 sentry_crash_reporter.exe*
-rw-r--r-- 1 jpnurmi 197610 11M Aug 13 10:52 sentry_crash_reporter.pdb
-rwxr-xr-x 1 jpnurmi 197610 1.2M Aug 13 10:52 sentry_example.exe*
-rw-r--r-- 1 jpnurmi 197610 11M Aug 13 10:52 sentry_example.pdb
-rwxr-xr-x 1 jpnurmi 197610 1.1M Aug 13 10:52 sentry_fuzz_json.exe*
-rw-r--r-- 1 jpnurmi 197610 12M Aug 13 10:52 sentry_fuzz_json.pdb
-rwxr-xr-x 1 jpnurmi 197610 1.2M Aug 13 10:52 sentry_screenshot.exe*
-rw-r--r-- 1 jpnurmi 197610 12M Aug 13 10:52 sentry_screenshot.pdb
-rwxr-xr-x 1 jpnurmi 197610 1.4M Aug 13 10:52 sentry_test_unit.exe*
-rw-r--r-- 1 jpnurmi 197610 12M Aug 13 10:52 sentry_test_unit.pdb
-rw-r--r-- 1 jpnurmi 197610 273 Aug 13 10:52 view-hierarchy.json |
The sizes look reasonable with jpnurmi@surface MINGW64 ~/Projects/sentry/sentry-native (feat/feedback-handler)
$ ls -lah build/manual-json/RelWithDebInfo/
total 58M
drwxr-xr-x 1 jpnurmi 197610 0 Aug 13 12:50 ./
drwxr-xr-x 1 jpnurmi 197610 0 Aug 13 12:50 ../
-rwxr-xr-x 1 jpnurmi 197610 1.3M Aug 13 12:50 crashpad_handler.exe*
-rw-r--r-- 1 jpnurmi 197610 13M Aug 13 12:50 crashpad_handler.pdb
-rwxr-xr-x 1 jpnurmi 197610 38K Aug 13 12:48 crashpad_wer.dll*
-rw-r--r-- 1 jpnurmi 197610 604K Aug 13 12:48 crashpad_wer.pdb
-rw-r--r-- 1 jpnurmi 197610 42K Aug 13 12:50 minidump.dmp
-rw-r--r-- 1 jpnurmi 197610 2.4M Aug 13 12:50 sentry.lib
-rw-r--r-- 1 jpnurmi 197610 868K Aug 13 12:50 sentry.pdb
-rwxr-xr-x 1 jpnurmi 197610 782K Aug 13 12:50 sentry_crash_reporter.exe*
-rw-r--r-- 1 jpnurmi 197610 7.0M Aug 13 12:50 sentry_crash_reporter.pdb
-rwxr-xr-x 1 jpnurmi 197610 842K Aug 13 12:50 sentry_example.exe*
-rw-r--r-- 1 jpnurmi 197610 7.0M Aug 13 12:50 sentry_example.pdb
-rwxr-xr-x 1 jpnurmi 197610 787K Aug 13 12:49 sentry_fuzz_json.exe*
-rw-r--r-- 1 jpnurmi 197610 7.0M Aug 13 12:49 sentry_fuzz_json.pdb
-rwxr-xr-x 1 jpnurmi 197610 836K Aug 13 12:50 sentry_screenshot.exe*
-rw-r--r-- 1 jpnurmi 197610 7.0M Aug 13 12:50 sentry_screenshot.pdb
-rwxr-xr-x 1 jpnurmi 197610 1.1M Aug 13 12:49 sentry_test_unit.exe*
-rw-r--r-- 1 jpnurmi 197610 7.7M Aug 13 12:49 sentry_test_unit.pdb
-rw-r--r-- 1 jpnurmi 197610 273 Aug 13 12:50 view-hierarchy.j |
be621fd
to
f7b3970
Compare
Hey @supervacuus, is it ok to merge this? I think it's ready to go, but there were significant changes after the approval. I ended up dropping I agree that keeping crashpad unaware of the msg-packed attachments would be nice in principle, but passing them unprocessed to the external crash reporter would force the external crash reporter to special-case crashpad envelopes and do non-trivial pre-processing before being able to submit envelopes to Sentry. |
When an external crash reporter is registered, instead of posting minidump + attachments straight to Sentry, Crashpad now dumps them into an envelope, spawns and detaches the external crash reporter process, and passes the envelope as an argument.
Required for: