-
-
Notifications
You must be signed in to change notification settings - Fork 339
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: Potential deadlock in app hang detection #4063
fix: Potential deadlock in app hang detection #4063
Conversation
The app hang detection retrieves the stacktraces of all threads when it detects an app hang. The logic for retrieving the stacktrace uses sentrycrashdl_dladdr, which isn't async-safe, although it claims to be because it accesses _dyld_get_image_header, which acquires a lock. Therefore, in rare cases, retrieving the stacktrace for all threads can lead to a deadlock. We fix this by skipping symbolication, which calls sentrycrashdl_dladdr when debug is false, which we we thought we did in Fixes GH-4056
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4063 +/- ##
=============================================
+ Coverage 91.158% 91.207% +0.049%
=============================================
Files 611 611
Lines 48100 48130 +30
Branches 17273 17272 -1
=============================================
+ Hits 43847 43898 +51
+ Misses 4162 4139 -23
- Partials 91 93 +2
... and 6 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
2af280d | 1246.22 ms | 1253.10 ms | 6.88 ms |
4977fbc | 1217.26 ms | 1239.82 ms | 22.56 ms |
cf97209 | 1211.20 ms | 1233.31 ms | 22.10 ms |
9e6665f | 1233.33 ms | 1257.14 ms | 23.81 ms |
ef5821b | 1253.18 ms | 1265.46 ms | 12.28 ms |
3912b16 | 1230.54 ms | 1249.65 ms | 19.11 ms |
59ea421 | 1258.83 ms | 1272.55 ms | 13.72 ms |
1437c68 | 1244.86 ms | 1254.18 ms | 9.32 ms |
9ef729b | 1228.79 ms | 1245.36 ms | 16.57 ms |
e2abb0d | 1235.08 ms | 1257.00 ms | 21.92 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
2af280d | 20.76 KiB | 435.22 KiB | 414.46 KiB |
4977fbc | 20.76 KiB | 419.85 KiB | 399.10 KiB |
cf97209 | 21.58 KiB | 632.16 KiB | 610.58 KiB |
9e6665f | 22.84 KiB | 403.52 KiB | 380.67 KiB |
ef5821b | 21.58 KiB | 414.96 KiB | 393.37 KiB |
3912b16 | 21.58 KiB | 625.82 KiB | 604.24 KiB |
59ea421 | 22.85 KiB | 413.45 KiB | 390.60 KiB |
1437c68 | 22.85 KiB | 410.96 KiB | 388.11 KiB |
9ef729b | 20.76 KiB | 432.88 KiB | 412.12 KiB |
e2abb0d | 20.76 KiB | 434.72 KiB | 413.96 KiB |
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 looks good. I just dont see how this could help in an AppHang deadlock.
AFAIK being async-safe is not a requirement to use in a background thread when the main thread is busy. We use objc during ANR detection which is also not async-safe
Looking at the stracktrace posted in #4056 you can see that
Is it clearer now @brustolin or am I missing something? |
Ow, this is the problem! Now I remember, thanks!! |
📜 Description
The app hang detection retrieves the stacktraces of all threads when it detects an app hang. The logic for retrieving the stacktrace uses sentrycrashdl_dladdr, which isn't async-safe, although it claims to be because it accesses _dyld_get_image_header, which acquires a lock. Therefore, in rare cases, retrieving the stacktrace for all threads can lead to a deadlock. We fix this by skipping symbolication, which calls sentrycrashdl_dladdr when debug is false, which we we thought we did in #3079 but somehow missed for all threads.
💡 Motivation and Context
Fixes GH-4056
💚 How did you test it?
Setting debug=false for the iOS-Swift sample app to see if the symbolication still works. I wasn't able to reproduce the deadlock mentioned in GH-4056, but according to the description this fix should fix the problem.
📝 Checklist
You have to check all boxes before merging:
sendDefaultPII
is enabled.🔮 Next steps