Skip to content

fix(sdk-crash): Ignore CoreData tracker as only SDK frame#116556

Open
philprime wants to merge 2 commits into
masterfrom
fix/ignore-coredata-tracker-sdk-crash-false-positives
Open

fix(sdk-crash): Ignore CoreData tracker as only SDK frame#116556
philprime wants to merge 2 commits into
masterfrom
fix/ignore-coredata-tracker-sdk-crash-false-positives

Conversation

@philprime
Copy link
Copy Markdown
Member

Summary

Adds SentryCoreDataTracker and SentryCoreDataSwizzlingHelper to the Cocoa SDK's sdk_crash_ignore_when_only_sdk_frame_matchers, preventing false-positive SDK crash reports when these instrumentation frames are the only SDK frames in the stack.

Context

SDK-CRASHES-COCOA-59A has 50K+ occurrences of NSInvalidArgumentException (doesNotRecognizeSelector:) where the crash originates inside CoreData internals — merge policy constraint resolution or validation logging — not in our SDK code. Our CoreData swizzling transparently wraps save:/executeFetchRequest: with tracing spans and calls the original implementation unchanged. The crashes would occur identically without our swizzling.

This follows the same pattern as the existing SentrySwizzleWrapper exclusion.

Changes

  • Config: Added two FunctionAndModulePattern entries for SentryCoreDataTracker and SentryCoreDataSwizzlingHelper
  • Tests: Added CocoaSDKCoreDataTrackerTestMixin with two tests:
    • CoreData tracker frames as only SDK frames → not reported
    • CoreData tracker frames with another real SDK frame → still reported

Fixes SDK-CRASHES-COCOA-59A

#skip-changelog

Add SentryCoreDataTracker and SentryCoreDataSwizzlingHelper to the
Cocoa SDK's sdk_crash_ignore_when_only_sdk_frame_matchers. These frames
swizzle NSManagedObjectContext save:/executeFetchRequest: to add tracing
spans and transparently call the original implementation. Crashes inside
CoreData internals (doesNotRecognizeSelector: during merge policy or
validation) are app-level misconfigurations, not SDK bugs.

Fixes SDK-CRASHES-COCOA-59A
@philprime philprime requested a review from a team as a code owner June 1, 2026 08:18
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 1, 2026
@philprime philprime self-assigned this Jun 1, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

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 2 potential issues.

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 8133f80. Configure here.

Comment thread tests/sentry/utils/sdk_crashes/test_sdk_crash_detection_cocoa.py
Comment thread tests/sentry/utils/sdk_crashes/test_sdk_crash_detection_cocoa.py
Comment thread tests/sentry/utils/sdk_crashes/test_sdk_crash_detection_cocoa.py
@philprime philprime marked this pull request as draft June 1, 2026 08:24
Move SentryCoreDataSwizzlingHelper to sdk_crash_ignore_matchers
(unconditional) so it doesn't inflate the conditional frame count.
The detector only suppresses when conditional_sdk_frame_count == 1,
but CoreData stacks always have both the helper and tracker frames.
By unconditionally ignoring the helper, only SentryCoreDataTracker
remains as the single conditional frame.

Also add missing @patch decorator to test mixin.
Copy link
Copy Markdown
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-approving, but perhaps the bots comments need addressing

@philprime philprime marked this pull request as ready for review June 1, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants