Repository navigation
Send a fatal panic as the panic, not as the frameless abort it caused - #155
Merged
Merged
Conversation
A Rust panic that unwinds out of an `extern "C"` frame aborts, so one death leaves two records: the panic hook's `*** RUST PANIC ... at file:line` in the crash log, and the Sentry daemon's SIGABRT envelope, whose unwind stops at `__libc_do_syscall`. Boot queued the envelope first and then dropped every log record matching it by (build, signal), counting a panic as SIGABRT. The one record naming a source line was always the one discarded: production has not shown a single panic in 90 days, and fatal panics arrive as SIGABRTs grouped on a libc frame (PLX-NATIVE-W). The two channels are now recovered together. `native::read_pending` parses envelopes without queueing them; `crashreport::reconcile` pairs them with the log's fresh records; a panic replaces its SIGABRT envelope, while a fault is still sent as the daemon's richer event. `execute` owns the order of every append, delete and watermark write, so a cut between any two steps yields neither a lost report nor two events: a replaced envelope is deleted before the mark moves, a fault's winner only after the mark is known to have persisted. The mid-session consent path keeps importing envelopes alone, since the live log can hold this process's caught panics. Co-Authored-By: Claude Opus 5 <[email protected]>
Measured on the dev set: a panic that aborts at an `extern "C"` frame writes three crash-log records, not two. Std cannot unwind out of the frame, so it raises `panic in a function that cannot unwind` from `core::panicking`, and the hook logs that as a second panic. Both were sent: one death, two Sentry events. `parse` now folds that follow-up (and `panic in a destructor during cleanup`) into the panic immediately before it, by the same positional rule that already folds the abort. `crashtest=panic` exercises the panic-versus-envelope pairing. A bare `panic!` in `crash_on_purpose` unwinds `plex_run`'s own frame, which drops the telemetry Guard and deletes the native database before the abort, so no envelope is ever written. The panic now happens inside an `extern "C"` callback, the shape of `ff::read_cb` under libav. Co-Authored-By: Claude Opus 5 <[email protected]>
GLinnik21
added a commit
that referenced
this pull request
Sep 19, 2026
… read no crash data without a DSN (#168) Three follow-ups to the native crash-report import (#155): - The telemetry Guard no longer stops the native backend or deletes its database while the thread is unwinding a panic. A panic that unwinds plex_run's frame aborts at the extern "C" boundary a moment later, and that abort is the crash the backend exists to capture. A clean exit still shuts it down as before. - A pending native envelope that fails to READ (metadata, open or read I/O error) is left on disk for the next boot and counted as deferred=, instead of being deleted as malformed. Only a non-regular file, an oversized file, or bytes the parser refuses are deleted. - Crash data (the crash log and the native envelopes) is read only when crash consent is given AND the build carries a Sentry DSN, through one gate, crashreport::may_read_crash_data. A no-DSN build reads nothing, moves no watermark and deletes no envelope. Co-authored-by: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Rust panic that unwinds out of an
extern "C"frame aborts, so one death writes two records: the panic hook's*** RUST PANIC [..] at file:lineline in the crash log, and the Sentry daemon's SIGABRT envelope. The daemon's unwind stops at__libc_do_syscall, so the envelope has no useful frames.At boot,
native::import_pendingqueued the envelope first.consume_native_matchthen dropped every crash-log record matching it by (build id, signal), and it counted a panic as SIGABRT. So the one record that names a source line was always the one thrown away. In production: no panic issues in 90 days, and fatal panics show up as SIGABRTs grouped on a libc frame (PLX-NATIVE-W). The existing testone_native_envelope_suppresses_exactly_one_matching_fallbackasserted that behavior.Change
native::read_pendingparses envelopes without queueing them.PendingNative::{append, delete}commits them.crashreport::reconcileis a pure function that pairs fresh log records with envelopes one-to-one. A panic replaces its SIGABRT envelope. A fault (SIGSEGV, …) is still sent as the daemon's event, which carries frames and registers.crashreport::executeruns the plan through a smallRecoverytrait, so the order of side effects is tested with a recording fake:A cut between any two steps leaves neither a lost report nor two events for one death. The log side re-reads with deterministic
event_id_forids, and the native side re-imports with the envelope's own id.No fresh log, no log at all, or an empty parse: every envelope is still queued.
native::sync_change(mid-session opt-in) still imports envelopes on their own, as before, and does not reconcile against the live log. That log can contain this process's caught panics, which should not be reported as fatal.Deliberately out of scope
These are unchanged from before this PR:
Also fixed (found on the device)
extern "C"frame writes three crash-log records: the panic, then std'spanic in a function that cannot unwindfromcore::panicking, thenSIGNAL 6.parsealready folded the abort into the panic, but not the middle record, so the follow-up went out as a second event. It now folds that record, andpanic in a destructor during cleanup, into the panic immediately before it.crashtest=paniccould not reach the pairing. A barepanic!insideplex_rununwindsplex_run's own frame. That drops the telemetryGuard, which stops the native backend and deletes its database before the abort, so no envelope is ever written. The trigger now panics inside anextern "C"callback, which is the shape offf::read_cbunder libav.Verification
Host
a_panic_is_not_hidden_by_the_native_abort_it_causedfailed with "the native SIGABRT hid the panic that caused it".a_panic_its_cannot_unwind_followup_and_the_abort_are_one_reportfailed with "one death reported as 2 events", using the exact record the TV wrote.make check: exit 0 (3738 + 3784 tests).make lint: exit 0.make: exit 0.make RELEASE=1: exit 0.--no-default-features: clean.Device (dev set, webOS 4.10.2, debug install, dev DSN, crash consent on, TV lock held, 2026-09-19)
plx-native-devcrashtest=panicinsideplex_runcrash log had 2 report(s) … native envelopes 0dev.rs:377andpanicking.rs:225: two events for one death (this was the bug)crashtest=abrt1 report(s), queued 0, native envelopes 1, native_wins=11 report(s), queued 1, native envelopes 0(boot D's panic)dev.rs:377event, follow-up folded ✔1 report(s), queued 1, native envelopes 1, native_wins=0, panic_wins=1; pending dir emptydev.rs:380panic sent; its native SIGABRT was not ✔One review round with Codex. Its one real finding (a watermark write whose failure was ignored, which could have deleted a fault's winning envelope) is fixed and tested. Copilot couldn't review: quota exhausted.
🤖 Generated with Claude Code