Skip to content

Tombstone events discarded from beforeSend are re-reported on every app launch #5973

Description

@gabriele-mazzotta-amo

Integration

sentry-android-ndk

Build System

Gradle

AGP Version

9.3.0

Proguard

Enabled

Other Error Monitoring Solution

No

Version

8.40.0

Steps to Reproduce

  1. Force a native crash, so that the OS records a Tombstone
  2. Restart the app: BeforeSendCallback is called for that crash (possibly a TombstoneMerged), discard it
  3. Restart the app again: BeforeSendCallback is called with a new event (Tombstone), carrying a different event timestamp, discard it
  4. Restart the app again: BeforeSendCallback is called with a new event (Tombstone), with the same event timestamp, discard it
  5. Every subsequent restart does the same, until the event is not discarded

Expected Result

Tombstone events discarded from SentryOptions.BeforeSendCallback are reported again at every app launch, until one of them is not discarded. This makes it hard to drop them based on some heuristic. A discarded crash should stay discarded.

As far as I can tell, this happens because the LAST_TOMBSTONE_REPORT marker is not written if the event is discarded.

We currently work around that by retrieving the crash timestamp from the hint, through the internal HintUtils.getSentrySdkHint() and NativeCrashExit, and use that in our heuristic. The timestamp of the event passed to BeforeSendCallback proved to be insufficient as the same crash can be first passed as TombstoneMerged and as a seemingly different Tombstone with a different event timestamp at a subsequent app start.

This behavior is a bit surprising, especially because it differs from how signalhandler events are handled. If this was intended and this is not a bug, please provide an easy way to discard events reliably without having to rely on internal APIs.

I believe the same holds true for ANRs, but I haven't really looked at those.

Actual Result

N/A

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions