Skip to content
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

fix(sdk-crashes): Improve Cocoa crash detection #52119

Merged
merged 2 commits into from
Jul 4, 2023

Conversation

philipphofmann
Copy link
Member

This PR seems huge, with almost 300 additions, but around 150 are test case stacktrace frame data.

This PR adds a test case with frames from a real-world crash caused by our MetricKit integration. All data was anonymized. While adding the test case, a couple of problems surfaced that this PR addresses:

  1. Correctly detect crashes from Swift files starting with SentryMX.
  2. Correctly detect crashes from class extensions such as NSDate(SentryExtras).
  3. Ignore in_app when detecting an SDK crash, as customers can change the in_app rules. Furthermore, if they use static linking for including Sentry Cocoa, Cocoa SDK frames can be marked as in_app. Instead, the algorithm only checks if frames are SDK frames or from system libraries.

This PR adds a test case with frames from a real-world crash
caused by our MetricKit integration. All data was anonymized.
While adding the test case, a couple of problems surfaced
that this PR addresses:
1. Correctly detect crashes from Swift files starting with SentryMX.
2. Correctly detect crashes from class extensions such as
NSDate(SentryExtras).
3. Ignore in_app when detecting an SDK crash, as customers can
change the in_app rules. Furthermore, if they use static linking for
including Sentry Cocoa, Cocoa SDK frames can be marked as
in_app. Instead, the algorithm only checks if frames are SDK frames
or from system libraries.
@philipphofmann philipphofmann requested a review from a team July 4, 2023 11:14
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 4, 2023
@@ -44,3 +54,14 @@ def is_sdk_frame(self, frame: Mapping[str, Any]) -> bool:
return True

return False

def is_system_library_frame(self, frame: Mapping[str, Any]) -> bool:
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved this function from event_stripper to there.

@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Merging #52119 (02c2102) into master (bd53a6c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 02c2102 differs from pull request most recent head 572b8f0. Consider uploading reports for the commit 572b8f0 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #52119   +/-   ##
=======================================
  Coverage   79.31%   79.31%           
=======================================
  Files        4901     4901           
  Lines      205111   205123   +12     
  Branches    35063    35065    +2     
=======================================
+ Hits       162689   162702   +13     
- Misses      37460    37462    +2     
+ Partials     4962     4959    -3     
Impacted Files Coverage Δ
...ntry/utils/sdk_crashes/cocoa_sdk_crash_detector.py 89.47% <100.00%> (-3.86%) ⬇️
src/sentry/utils/sdk_crashes/event_stripper.py 84.31% <100.00%> (-2.13%) ⬇️
src/sentry/utils/sdk_crashes/sdk_crash_detector.py 100.00% <100.00%> (ø)

... and 7 files with indirect coverage changes

@philipphofmann philipphofmann enabled auto-merge (squash) July 4, 2023 13:47
@philipphofmann philipphofmann enabled auto-merge (squash) July 4, 2023 13:47
@philipphofmann philipphofmann merged commit e110e46 into master Jul 4, 2023
@philipphofmann philipphofmann deleted the fix/sdk-crash-improvements branch July 4, 2023 14:10
@github-actions github-actions bot locked and limited conversation to collaborators Jul 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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