-
-
Notifications
You must be signed in to change notification settings - Fork 334
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
Sentry 8.11.0 hangs Main thread on internal sync lock #3277
Comments
While, I'm not seeing this exact same issue. I am experiencing some race conditions when starting and finishing spans that are causing memory corruption after upgrading to |
I have the same bug. closing the file io trace fix this issue |
Thanks for the reports and info everyone, we're investigating. |
So far I haven't been able to reproduce this. @username0x0a , can you tell me if this is in a SwiftUI app or uses Swift async? Are you starting the Sentry SDK from a main actor context or otherwise? Any additional info you can provide would be helpful! |
@armcknight I will try and create a reproducible test case for the issue I am seeing which may or may not be related to this bug report. In my case, it's a SwiftUI app and sentry is being invoked from a Swift async context and not the main thread or Removing the |
@armcknight We're initialising The situation is quite simple, tho:
TL;DR: some Also, the above swizzle of |
Thanks for the very informative replies! @username0x0a, I also looked at that As for the data race in span start/finish, that is something we do have some tests for but so far unable to reproduce. I'm standing by to see if you are able to put something together @scogeo , or to try more experiments if you're unable to. |
Happy to help. 👍 I guess this code piece: - (SentryUIDeviceWrapper *)uiDeviceWrapper
{
if (_uiDeviceWrapper == nil) {
@synchronized(sentryDependencyContainerLock) {
if (_uiDeviceWrapper == nil) {
_uiDeviceWrapper = [[SentryUIDeviceWrapper alloc] init];
// ^^^^^^^^^^^
}
}
}
return _uiDeviceWrapper;
} which immediately triggers: if (self = [super init]) {
// |---------- another `@synchronized` call
// v
[SentryDependencyContainer.sharedInstance.dispatchQueueWrapper dispatchSyncOnMainQueue:^{
// Needed to read the device orientation on demand
if (!UIDevice.currentDevice.isGeneratingDeviceOrientationNotifications) {
self.cleanupDeviceOrientationNotifications = YES;
[UIDevice.currentDevice beginGeneratingDeviceOrientationNotifications];
} from within the lock which re-enters the lock again 😅 talks for itself. I'd say as far as Of course, one another thing would be to have dependencies properly aligned & not use any |
@armcknight I may have some time to look at this towards the end of the week. If you find anything in the interim please let me know. |
You have closed #3293 but that may be a separate issue, you may want to re-open and at least investigate. When I run the iOS target of my app, which shares the same code base as the macCatalyst app I do not get the app hanging on startup. App starts up just fine on iOS 17 sim with Sentry SDK 8.12 |
@armcknight FYI, Updating to |
That's great news @scogeo ! 🎉 Thanks to @brustolin for writing the fix 🙏🏻 🥔 |
Platform
iOS
Installed
Swift Package Manager
Version
8.11.0
Steps to Reproduce
Expected Result
App not hanging
Actual Result
App hanging. We've only discovered after…finding an increasing number of
WatchdogTermination
issues in Sentry soon after a release. :crazy-laugh: 🤦♂️This is caused by a re-entry into the
@sychrnoized(...)
lock in-[SentryDependencyContainer uiDeviceWrapper]
:which has been introduced in
8.11.0
update & has a potential to deadlock if re-entries around the@synchronized(sentryDependencyContainerLock)
aren't sanitised properly.“Luckily”, this also involves Main thread at some point so that it causes the issue to become visible sooner or later (app freezes dead); I can't even imagine the catastrophe if this'd silently happen purely on non-Main threads.
Here's a stack trace of colliding threads locking simultaneously:
Are you willing to submit a PR?
No response
The text was updated successfully, but these errors were encountered: