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

App Sometimes Hangs during vm_deallocate in BSG_KSMach.c #240

Closed
YusufSoomro opened this issue Feb 8, 2018 · 7 comments
Closed

App Sometimes Hangs during vm_deallocate in BSG_KSMach.c #240

YusufSoomro opened this issue Feb 8, 2018 · 7 comments

Comments

@YusufSoomro
Copy link

Expected behavior

The app should not hang when trying to report a bug.

Observed behavior

Sometimes the app will hang indefinitely and not crash when trying to send a Bugsnag. When we hit Pause in Xcode, we get a stack trace that shows the app is trying to execute but unable complete this line fo code:

Thread 1 Queue : com.apple.main-thread (serial)
#0	0x0000000109b448d6 in syscall_thread_switch ()
#1	0x0000000109b72d0c in _os_lock_handoff_lock_slow ()
#2	0x000000010994a6e2 in __disk_stack_logging_log_stack ()
#3	0x0000000109b4ca36 in mach_vm_deallocate ()
#4	0x0000000101a469ca in bsg_ksmachsuspendAllThreadsExcept at /Users/mobiledev/workspace/ios-app/Pods/Bugsnag/Source/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.c:356
#5	0x0000000101a37dfb in bsg_kscrashsentry_suspendThreads at /Users/mobiledev/workspace/ios-app/Pods/Bugsnag/Source/KSCrash/Source/KSCrash/Recording/Sentry/BSG_KSCrashSentry.c:164
#6	0x0000000101a3a3d5 in bsg_kscrashsentry_reportUserException at /Users/mobiledev/workspace/ios-app/Pods/Bugsnag/Source/KSCrash/Source/KSCrash/Recording/Sentry/BSG_KSCrashSentry_User.c:63
#7	0x0000000101a2b038 in bsg_kscrash_reportUserException at /Users/mobiledev/workspace/ios-app/Pods/Bugsnag/Source/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c:249
#8	0x0000000101a2947f in -[BSG_KSCrash reportUserException:reason:language:lineOfCode:stackTrace:terminateProgram:] at /Users/mobiledev/workspace/ios-app/Pods/Bugsnag/Source/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m:373
#9	0x0000000101a642ec in -[BugsnagCrashSentry reportUserException:reason:] at /Users/mobiledev/workspace/ios-app/Pods/Bugsnag/Source/BugsnagCrashSentry.m:47
#10	0x0000000101a6de29 in -[BugsnagNotifier notify:message:handledState:block:] at /Users/mobiledev/workspace/ios-app/Pods/Bugsnag/Source/BugsnagNotifier.m:565
#11	0x0000000101a6c625 in -[BugsnagNotifier notifyError:block:] at /Users/mobiledev/workspace/ios-app/Pods/Bugsnag/Source/BugsnagNotifier.m:443
#12	0x0000000101a545d0 in +[Bugsnag notifyError:] at /Users/mobiledev/workspace/ios-app/Pods/Bugsnag/Source/Bugsnag.m:94
#13	0x000000010107569a in closure #2 in ErrorReportingService.start() at /Users/mobiledev/workspace/ios-app/OmadaPrevent/ErrorReportingService.swift:33
#14	0x0000000102dcfbb7 in report(error:file:line:) at /Users/mobiledev/workspace/ios-app/SwiftOmada/Services/Analytics/ErrorReporting.swift:16
#15	0x000000010107c47d in closure #1 in DailyActivityManager.syncActivities(from:to:onSuccess:) at /Users/mobiledev/workspace/ios-app/OmadaPrevent/DailyActivityManager.swift:104
#16	0x0000000101082c40 in partial apply for closure #1 in DailyActivityManager.syncActivities(from:to:onSuccess:) ()
#17	0x0000000101082303 in closure #2 in DailyActivityManager.fetchActivities(from:to:completion:) at /Users/mobiledev/workspace/ios-app/OmadaPrevent/DailyActivityManager.swift:211
#18	0x000000010108371a in partial apply for closure #2 in DailyActivityManager.fetchActivities(from:to:completion:) ()
#19	0x0000000100ff0f8e in thunk for @callee_owned (@owned NetworkClientFailureResult) -> () ()
#20	0x0000000101078270 in thunk for @callee_unowned @convention(block) (@unowned NetworkClientFailureResult) -> () ()
#21	0x000000010110d40a in partial apply for thunk for @callee_unowned @convention(block) (@unowned NetworkClientFailureResult) -> () ()
#22	0x0000000100ff0f8e in thunk for @callee_owned (@owned NetworkClientFailureResult) -> () ()
#23	0x0000000100f75520 in __29-[OPNetworkClient onFailure:]_block_invoke at /Users/mobiledev/workspace/ios-app/OmadaPrevent/OPNetworkClient.m:142
#24	0x0000000101774d5d in __64-[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke_3 at /Users/mobiledev/workspace/ios-app/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m:123

Steps to reproduce

We are using Bugsnag 5.15.3.

We are making a network call to a server that is not available. We are using [Bugsnag notifyError:] as a method to notify about not crashing bugs. This used to work before to report without Bugsnag hanging.

This is the error that we are getting and trying to report to Bugsnag, but it shouldn't matter that it is this specific error:

Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x7fca4e91fd40 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "Could not connect to the server." UserInfo={NSErrorFailingURLStringKey=http://localhost:3000/api/mobile/v5/accounts/12/physical_activities?from=2018-02-02&to=2018-02-08, NSErrorFailingURLKey=http://localhost:3000/api/mobile/v5/accounts/12/physical_activities?from=2018-02-02&to=2018-02-08, _kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1, NSLocalizedDescription=Could not connect to the server.}}, NSErrorFailingURLStringKey=http://localhost:3000/api/mobile/v5/accounts/12/physical_activities?from=2018-02-02&to=2018-02-08, NSErrorFailingURLKey=http://localhost:3000/api/mobile/v5/accounts/12/physical_activities?from=2018-02-02&to=2018-02-08, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}

This will then result in hang of the app (but not crash) as described in the observed behavior above.

Version

Bugsnag 5.15.3

@kattrali
Copy link
Contributor

kattrali commented Feb 8, 2018

Thanks for the report, @YusufSoomro. Looking into it.

@benasher44
Copy link

Thanks @kattrali! I noticed this recently as well. Happy to try to reproduce and help provide more info if needed here as well.

@kattrali
Copy link
Contributor

@benasher44 do you have a simple case for reproduction, such as an example project or particular device?

@benasher44
Copy link

benasher44 commented Feb 13, 2018

I don't sorry. Here's all of the info from when I could consistently repo it:

  • iPad Air 2 / iOS 11 simulator (latest Xcode 9.2)
  • The app was making a few network requests and had lots of threads doing background DB work (would generally describe this scenario has heavy CPU load for our app).
  • During that time, a network request timed out, and we attempted to call notifyError. Then, I noticed that loading spinners appeared to never stop, and that's when I realized I could no longer interact with the sim. I pressed pause in the Xcode debugger, and I found nearly the same trace as is posted in the description.

I hope that helps!

@kattrali
Copy link
Contributor

Thanks @benasher44!

@paulz
Copy link
Contributor

paulz commented Mar 16, 2018

Same method looks like deadlock on the main thread:

#0	0x0000000182c4cbe0 in __ulock_wait ()
#1	0x0000000182d5aca4 in _os_unfair_lock_lock_slow ()
#2	0x0000000182c957a0 in __disk_stack_logging_log_stack ()
#3	0x0000000182c2b744 in mach_vm_deallocate ()
#4	0x0000000104cd12ec in bsg_ksmachsuspendAllThreadsExcept at /Users/developer/workspace/ios-app/Pods/Bugsnag/Source/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.c:356
#5	0x0000000104cc26b8 in bsg_kscrashsentry_suspendThreads at /Users/developer/workspace/ios-app/Pods/Bugsnag/Source/KSCrash/Source/KSCrash/Recording/Sentry/BSG_KSCrashSentry.c:164
#6	0x0000000104cc4e5c in bsg_kscrashsentry_reportUserException at /Users/developer/workspace/ios-app/Pods/Bugsnag/Source/KSCrash/Source/KSCrash/Recording/Sentry/BSG_KSCrashSentry_User.c:63
#7	0x0000000104cb5b78 in bsg_kscrash_reportUserException at /Users/developer/workspace/ios-app/Pods/Bugsnag/Source/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c:249
#8	0x0000000104cb3e0c in -[BSG_KSCrash reportUserException:reason:language:lineOfCode:stackTrace:terminateProgram:] at /Users/developer/workspace/ios-app/Pods/Bugsnag/Source/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m:373
#9	0x0000000104cef5d4 in -[BugsnagCrashSentry reportUserException:reason:] at /Users/developer/workspace/ios-app/Pods/Bugsnag/Source/BugsnagCrashSentry.m:47
#10	0x0000000104cf8f74 in -[BugsnagNotifier notify:message:handledState:block:] at /Users/developer/workspace/ios-app/Pods/Bugsnag/Source/BugsnagNotifier.m:565
#11	0x0000000104cf785c in -[BugsnagNotifier notifyError:block:] at /Users/developer/workspace/ios-app/Pods/Bugsnag/Source/BugsnagNotifier.m:443
#12	0x0000000104cdf43c in +[Bugsnag notifyError:] at /Users/developer/workspace/ios-app/Pods/Bugsnag/Source/Bugsnag.m:94

@mattdyoung
Copy link

We were never able to reproduce this issue, but it should no longer be possible following the changes made in v5.22.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants