Infinite loop in pthread_from_mach_thread_np freezing app - ios

I am investigating an issue for an iOS app where the main thread appears to be hung. It believe I have reproduced it locally a couple times, but it is not very repeatable. I have attached a few example stack traces below where I have seen this.
I see a dispatch_barrier_sync_f call which “submits a barrier function for execution and waits until that function completes”. This is happening on a number of the other threads which are all waiting on a ulock_wait.
In all of the hangs, there is one thread that has a dispatch_barrier_sync_f which appears to be active. From what we could tell, it is stuck in the function pthread_from_mach_thread_np. I only have assembly code here, but here is some source. It appears to be converting from a mach_thread to a pthread. When I step through the assembly it appears to be stuck in the loop portion of iterating over the pthread list.
It is not clear to me how this fixed loop could hang. Perhaps the memory is corrupted and it is not looping over a valid pthread list?
This may be related to the issue posted here.
I have a few examples of this happening all from different services
Example 1:
thread #104, queue = 'com.apple.coremedia.decompressionsession.clientcallback'
frame #0: 0x00000001f17fc100 libsystem_pthread.dylib`pthread_from_mach_thread_np + 68
frame #1: 0x0000000109139c98 libdispatch.dylib`_dispatch_introspection_continuation_get_info + 244
frame #2: 0x000000010913ae74 libdispatch.dylib`_dispatch_introspection_queue_item_enqueue_hook + 44
frame #3: 0x000000010913a42c libdispatch.dylib`_dispatch_introspection_queue_fake_sync_push_pop + 116
frame #4: 0x0000000109107f1c libdispatch.dylib`_dispatch_barrier_sync_f + 224
frame #5: 0x0000000197286720 VideoToolbox`__vtdsr_dequeueAllPendingFramesAndCallbackClientForEach_block_invoke + 1000
frame #6: 0x0000000109100c6c libdispatch.dylib`_dispatch_call_block_and_release + 32
frame #7: 0x00000001091027bc libdispatch.dylib`_dispatch_client_callout + 20
frame #8: 0x000000010910aa60 libdispatch.dylib`_dispatch_lane_serial_drain + 1428
frame #9: 0x000000010910b5e0 libdispatch.dylib`_dispatch_lane_invoke + 428
frame #10: 0x0000000109118168 libdispatch.dylib`_dispatch_workloop_worker_thread + 908
frame #11: 0x00000001f17f60bc libsystem_pthread.dylib`_pthread_wqthread + 288
Example 2:
thread #97
frame #0: 0x00000001f0b980ec libsystem_pthread.dylib`pthread_from_mach_thread_np + 48
frame #1: 0x00000001059f9c98 libdispatch.dylib`_dispatch_introspection_continuation_get_info + 244
frame #2: 0x00000001059fae74 libdispatch.dylib`_dispatch_introspection_queue_item_enqueue_hook + 44
frame #3: 0x00000001059fa42c libdispatch.dylib`_dispatch_introspection_queue_fake_sync_push_pop + 116
frame #4: 0x00000001059c7f1c libdispatch.dylib`_dispatch_barrier_sync_f + 224
frame #5: 0x0000000187fbbf54 CoreData`_perform + 176
frame #6: 0x0000000187e23a28 CoreData`-[NSPersistentStoreCoordinator _routeLightweightBlock:toStore:] + 204
frame #7: 0x0000000187ea71f4 CoreData`-[NSPersistentStoreCoordinator(_NSInternalMethods) newValuesForObjectWithID:withContext:error:] + 368
frame #8: 0x0000000187e89f7c CoreData`_PFFaultHandlerLookupRow + 296
frame #9: 0x0000000187ec357c CoreData`_PF_FulfillDeferredFault + 208
frame #10: 0x0000000187e25fc8 CoreData`_PF_ManagedObject_WillChangeValueForKeyIndex + 84
frame #11: 0x0000000187e3f260 CoreData`_sharedIMPL_setvfk_core + 152
frame #12: 0x000000010128f408 MyApp`-[GMSTileDataCache touchCachedTile:] + 100
frame #13: 0x000000010128fb7c MyApp`__72-[GMSTileDataCache loadTileForTileCoords:dataVersion:completionHandler:]_block_invoke + 216
frame #14: 0x0000000187e18834 CoreData`developerSubmittedBlockToNSManagedObjectContextPerform + 156
frame #15: 0x00000001059c27bc libdispatch.dylib`_dispatch_client_callout + 20
frame #16: 0x00000001059ca8a4 libdispatch.dylib`_dispatch_lane_serial_drain + 984
frame #17: 0x00000001059cb5e0 libdispatch.dylib`_dispatch_lane_invoke + 428
frame #18: 0x00000001059d8168 libdispatch.dylib`_dispatch_workloop_worker_thread + 908
frame #19: 0x00000001f0b920bc libsystem_pthread.dylib`_pthread_wqthread + 288
Example 3:
thread #99, queue = 'flight logger queue'
frame #0: 0x00000001f16040f8 libsystem_pthread.dylib`pthread_from_mach_thread_np + 60
frame #1: 0x0000000105909c98 libdispatch.dylib`_dispatch_introspection_continuation_get_info + 244
frame #2: 0x000000010590b0d0 libdispatch.dylib`_dispatch_introspection_queue_item_dequeue_hook + 44
frame #3: 0x000000010590a440 libdispatch.dylib`_dispatch_introspection_queue_fake_sync_push_pop + 136
frame #4: 0x00000001058d7f1c libdispatch.dylib`_dispatch_barrier_sync_f + 224
frame #5: 0x000000019ac06cac libswiftDispatch.dylib`merged implicit closure #2 (() -> ()) -> () in implicit closure #1 (__C.OS_dispatch_queue) -> (() -> ()) -> () in __C.OS_dispatch_queue.sync<τ_0_0>(execute: () throws -> τ_0_0) throws -> τ_0_0 + 180
frame #6: 0x000000019ac05d0c libswiftDispatch.dylib`partial apply forwarder for implicit closure #2 (() -> ()) -> () in implicit closure #1 (__C.OS_dispatch_queue) -> (() -> ()) -> () in __C.OS_dispatch_queue.sync<τ_0_0>(execute: () throws -> τ_0_0) throws -> τ_0_0 + 56
frame #7: 0x000000019ac069ec libswiftDispatch.dylib`__C.OS_dispatch_queue._syncHelper<τ_0_0>(fn: (() -> ()) -> (), execute: () throws -> τ_0_0, rescue: (Swift.Error) throws -> τ_0_0) throws -> τ_0_0 + 396
frame #8: 0x000000019ac05dbc libswiftDispatch.dylib`__C.OS_dispatch_queue.sync<τ_0_0>(execute: () throws -> τ_0_0) throws -> τ_0_0 + 168
frame #9: 0x0000000100324f8c MyApp`FlightData.flightDataComponents(self=0x000000010645aee0) at FlightData.swift:184:35
frame #10: 0x000000010029c014 MyApp`DDLogDataFactory.generateLogDataComponent(now=2022-06-30 22:54:33 UTC, flightData=0x000000010645aee0, self=0x0000000287465280) at DDLogDataFactory.swift:197:44
frame #11: 0x0000000100364688 MyApp`DDFlightLogFormatterV1.flightData(flightData=0x000000010645aee0, self=0x0000000283461040) at DDFlightLogFormatterV1.swift:45:57
frame #12: 0x0000000100364768 MyApp`#objc DDFlightLogFormatterV1.flightData(_:) at <compiler-generated>:0
frame #13: 0x00000001001d06b4 MyApp`__31-[FlightLogger logCurrentData:]_block_invoke(.block_descriptor=0x0000000283bc01b0) at FlightLogger.m:408:30
frame #14: 0x00000001001d0e40 MyApp`__41-[FlightLogger executeBlockInBackground:]_block_invoke(.block_descriptor=0x0000000283bc22b0) at FlightLogger.m:457:9
frame #15: 0x00000001058d0c6c libdispatch.dylib`_dispatch_call_block_and_release + 32
frame #16: 0x00000001058d27bc libdispatch.dylib`_dispatch_client_callout + 20
frame #17: 0x00000001058da8a4 libdispatch.dylib`_dispatch_lane_serial_drain + 984
frame #18: 0x00000001058db5e0 libdispatch.dylib`_dispatch_lane_invoke + 428
frame #19: 0x00000001058e8168 libdispatch.dylib`_dispatch_workloop_worker_thread + 908
frame #20: 0x00000001f15fe0bc libsystem_pthread.dylib`_pthread_wqthread + 288
Any help would be greatly appreciated, thank you

Related

Xcode UI Test Crashes for exists, isHittable, waitForExistence and recording

I have a very simple Xcode UI Test with this function:
func waitForElementToAppear(_ element: XCUIElement) -> Bool {
let predicate = NSPredicate(format: "exists == true")
let exp = expectation(for: predicate, evaluatedWith: element, handler: nil)
let result = XCTWaiter().wait(for: [exp], timeout: 10)
return result == .completed
}
Which has always worked for me before Xcode 9. I am not sure if this is an Xcode 10 issue, but it has recently started without me adding or changing any code.
Here is my test code:
func testTabBarPress() {
let tabbar = self.app.tabBars["my_tabbar"]
print(tabbar)
}
This test succeeds - always.
func testTabBarPress() {
let tabbar = self.app.tabBars["my_tabbar"]
print(tabbar)
if tabbar.isHittable {
}
}
This test fails - always. It does not JUST fail, it crashes with Thread 1: EXC_BAD_ACCESS (code=1, address=0x0).
After more than 99.945 seconds it switches from crashed state to failed test state with the message: Timeout waiting for fulfillment of promise for 'remote query'..
This test:
func testTabBarPress() {
let tabbar = self.app.tabBars["my_tabbar"]
print(tabbar)
if waitForElementToAppear(tabbar) {
}
}
Crashes with the same message of EXC_BAD_ACCESS but it does succeed afterwards.
I also did reset the simulators, cleaned the build folder and updated Xcode to 10.2.1 (10E1001)
At the top of my test I define my app:
private var app: XCUIApplication = XCUIApplication() and in setup() I launch it.
Any help appreciated. Thanks!
Edit:
Here is the stack trace:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x0000000113a833d0 libsystem_platform.dylib`_platform_strcmp + 80
frame #1: 0x00000001322086f1 UIKit`-[UIViewAccessibility _accessibilityRetrieveIvarText] + 364
frame #2: 0x00000001321f5e54 UIKit`-[UITableViewCellAccessibility _accessibilityRetrieveTableViewIvarsText] + 118
frame #3: 0x00000001321f6b27 UIKit`-[UITableViewCellAccessibility _accessibilityRetrieveTableViewCellText:] + 2749
frame #4: 0x00000001321f99c1 UIKit`-[UITableViewCellAccessibility accessibilityLabel] + 123
frame #5: 0x000000012ee47739 PreferencesFramework`-[UITableViewCellAccessibility__Preferences__UIKit accessibilityLabel] + 327
frame #6: 0x000000013243f31c UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityPotentiallyAttributedValueForNonAttributedSelector:attributedSelector:] + 244
frame #7: 0x000000013243f478 UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityAXAttributedLabel] + 41
frame #8: 0x00000001321d620e UIKit`-[UINavigationBarAccessibility_UIViewAccessibilityAdditions _accessibilityAXAttributedLabel] + 650
frame #9: 0x000000013220b711 UIKit`-[UITableViewCellAccessibilityElement accessibilityLabel] + 48
frame #10: 0x000000013243f31c UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityPotentiallyAttributedValueForNonAttributedSelector:attributedSelector:] + 244
frame #11: 0x000000013243f478 UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityAXAttributedLabel] + 41
frame #12: 0x000000013243e9ae UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityProcessedLabelAttribute] + 34
frame #13: 0x0000000132442c32 UIAccessibility`-[NSObject(AXPrivCategory) accessibilityAttributeValue:] + 268
frame #14: 0x000000013246cacd UIAccessibility`_accessibilityAttributesForObject + 493
frame #15: 0x000000013246c43a UIAccessibility`-[NSObject(UIAccessibilityAutomation) _accessibilityUserTestingSnapshotDescendantsWithAttributes:maxDepth:maxChildren:maxArrayCount:] + 1239
frame #16: 0x000000013246dfd9 UIAccessibility`-[NSObject(UIAccessibilityAutomation) _accessibilityUserTestingSnapshotWithOptions:] + 1139
frame #17: 0x0000000132441f09 UIAccessibility`-[NSObject(AXPrivCategory) accessibilityAttributeValue:forParameter:] + 8537
frame #18: 0x00000001321cb100 UIKit`-[UIApplicationAccessibility accessibilityAttributeValue:forParameter:] + 290
frame #19: 0x0000000132424657 UIAccessibility`_copyParameterizedAttributeValueCallback + 434
frame #20: 0x0000000130ef1629 AXRuntime`___AXXMIGCopyParameterizedAttributeValue_block_invoke + 50
frame #21: 0x0000000130ef0f99 AXRuntime`_handleNonMainThreadCallback + 55
frame #22: 0x0000000130ef14cb AXRuntime`_AXXMIGCopyParameterizedAttributeValue + 285
frame #23: 0x0000000130eec976 AXRuntime`AXUIElementCopyParameterizedAttributeValue + 495
frame #24: 0x0000000130e80351 XCTAutomationSupport`-[XCTAccessibilityFramework userTestingSnapshotForElement:options:error:] + 420
frame #25: 0x0000000130e77e90 XCTAutomationSupport`-[XCTElementSnapshotRequest(PlatformImplementation) accessibilitySnapshotOrError:] + 1263
frame #26: 0x0000000130e8305f XCTAutomationSupport`__56-[XCTElementSnapshotRequest loadSnapshotAndReturnError:]_block_invoke_2 + 64
frame #27: 0x0000000130e728dd XCTAutomationSupport`__XCTPerformOnMainRunLoop_block_invoke + 295
frame #28: 0x0000000111251aec CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
frame #29: 0x00000001112512b0 CoreFoundation`__CFRunLoopDoBlocks + 336
frame #30: 0x000000011124c10b CoreFoundation`__CFRunLoopRun + 2747
frame #31: 0x000000011124b302 CoreFoundation`CFRunLoopRunSpecific + 626
frame #32: 0x000000011748d2fe GraphicsServices`GSEventRunModal + 65
frame #33: 0x0000000119ea2ba2 UIKitCore`UIApplicationMain + 140
* frame #34: 0x000000010d2afa4b Musify`main at AppDelegate.swift:20:7
frame #35: 0x0000000113721541 libdyld.dylib`start + 1
frame #36: 0x0000000113721541 libdyld.dylib`start + 1
And here is a trace for a recording crash:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x0000000107c223d0 libsystem_platform.dylib`_platform_strcmp + 80
frame #1: 0x00000001269186f1 UIKit`-[UIViewAccessibility _accessibilityRetrieveIvarText] + 364
frame #2: 0x0000000126905e54 UIKit`-[UITableViewCellAccessibility _accessibilityRetrieveTableViewIvarsText] + 118
frame #3: 0x0000000126906b27 UIKit`-[UITableViewCellAccessibility _accessibilityRetrieveTableViewCellText:] + 2749
frame #4: 0x00000001269099c1 UIKit`-[UITableViewCellAccessibility accessibilityLabel] + 123
frame #5: 0x0000000123633739 PreferencesFramework`-[UITableViewCellAccessibility__Preferences__UIKit accessibilityLabel] + 327
frame #6: 0x0000000126b4f31c UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityPotentiallyAttributedValueForNonAttributedSelector:attributedSelector:] + 244
frame #7: 0x0000000126b4f478 UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityAXAttributedLabel] + 41
frame #8: 0x00000001268e620e UIKit`-[UINavigationBarAccessibility_UIViewAccessibilityAdditions _accessibilityAXAttributedLabel] + 650
frame #9: 0x000000012691b711 UIKit`-[UITableViewCellAccessibilityElement accessibilityLabel] + 48
frame #10: 0x0000000126b4f31c UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityPotentiallyAttributedValueForNonAttributedSelector:attributedSelector:] + 244
frame #11: 0x0000000126b4f478 UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityAXAttributedLabel] + 41
frame #12: 0x0000000126b4e9ae UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityProcessedLabelAttribute] + 34
frame #13: 0x0000000126b52c32 UIAccessibility`-[NSObject(AXPrivCategory) accessibilityAttributeValue:] + 268
frame #14: 0x0000000126b7cacd UIAccessibility`_accessibilityAttributesForObject + 493
frame #15: 0x0000000126b7c43a UIAccessibility`-[NSObject(UIAccessibilityAutomation) _accessibilityUserTestingSnapshotDescendantsWithAttributes:maxDepth:maxChildren:maxArrayCount:] + 1239
frame #16: 0x0000000126b7dfd9 UIAccessibility`-[NSObject(UIAccessibilityAutomation) _accessibilityUserTestingSnapshotWithOptions:] + 1139
frame #17: 0x0000000126b51f09 UIAccessibility`-[NSObject(AXPrivCategory) accessibilityAttributeValue:forParameter:] + 8537
frame #18: 0x00000001268db100 UIKit`-[UIApplicationAccessibility accessibilityAttributeValue:forParameter:] + 290
frame #19: 0x0000000126b34657 UIAccessibility`_copyParameterizedAttributeValueCallback + 434
frame #20: 0x00000001260bf629 AXRuntime`___AXXMIGCopyParameterizedAttributeValue_block_invoke + 50
frame #21: 0x00000001260bef99 AXRuntime`_handleNonMainThreadCallback + 55
frame #22: 0x00000001260bf4cb AXRuntime`_AXXMIGCopyParameterizedAttributeValue + 285
frame #23: 0x00000001260b94f0 AXRuntime`_XCopyParameterizedAttributeValue + 414
frame #24: 0x00000001260ce1b7 AXRuntime`mshMIGPerform + 237
frame #25: 0x00000001053ea419 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
frame #26: 0x00000001053e9a7b CoreFoundation`__CFRunLoopDoSource1 + 459
frame #27: 0x00000001053e400a CoreFoundation`__CFRunLoopRun + 2490
frame #28: 0x00000001053e3302 CoreFoundation`CFRunLoopRunSpecific + 626
frame #29: 0x000000010b62c2fe GraphicsServices`GSEventRunModal + 65
frame #30: 0x000000010e822ba2 UIKitCore`UIApplicationMain + 140
* frame #31: 0x00000001013dea4b Musify`main at AppDelegate.swift:20:7
frame #32: 0x00000001078c0541 libdyld.dylib`start + 1
frame #33: 0x00000001078c0541 libdyld.dylib`start + 1
By the way, recording and tapping on elements also crashes.
EDIT 2:
I figured out that using the Accessibility Identifier the App also crashes.. So I just need to hover over the Simulator to make the app crash. I am out of ideas :(

Crash on iOS 10.3.1 when inserting a UICollectionViewCell

I am moving across some content across from a different application, and doing so required me to move a NIB. Moving this NIB has caused a crash on iOS 10 which was occurring every time - this crash had no search results on stack overflow or much other information online.
I am reloading the cell using this code:
collectionView?.performBatchUpdates({
collectionView?.insertItems(at: [ indexPath ])
}, completion: nil)
Specifically, when inserting the collection view cell, this is the error:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x0000000105015acb libobjc.A.dylib`objc_msgSend + 11
frame #1: 0x0000000104c5506f Foundation`-[NSLayoutAnchor nsli_lowerIntoExpression:withCoefficient:forConstraint:] + 376
frame #2: 0x0000000104b21c11 Foundation`-[NSLayoutConstraint _lowerIntoExpression:reportingConstantIsRounded:] + 99
frame #3: 0x0000000104b1b56e Foundation`-[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 121
frame #4: 0x000000010721fc71 UIKit`__57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 454
frame #5: 0x0000000104b2182b Foundation`-[NSISEngine withBehaviors:performModifications:] + 155
frame #6: 0x000000010721fa84 UIKit`__57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 604
frame #7: 0x000000010721f800 UIKit`-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 223
frame #8: 0x000000010721e933 UIKit`-[UIView(AdditionalLayoutSupport) _initializeHostedLayoutEngine] + 447
frame #9: 0x0000000107211499 UIKit`-[UIView(UIConstraintBasedLayout) _layoutEngine_windowDidChange] + 130
frame #10: 0x0000000106917909 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 209
frame #11: 0x000000010690ab96 UIKit`__45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 151
frame #12: 0x000000010690aa7d UIKit`-[UIView(Hierarchy) _postMovedFromSuperview:] + 828
frame #13: 0x000000010691aa0a UIKit`-[UIView(Internal) _addSubview:positioned:relativeTo:] + 1927
frame #14: 0x000000010718aef7 UIKit`-[UICollectionView _addControlledSubview:atZIndex:] + 571
frame #15: 0x000000010718dec0 UIKit`-[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 1881
frame #16: 0x000000010718d761 UIKit`-[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 35
frame #17: 0x00000001071ac194 UIKit`__51-[UICollectionView _viewAnimationsForCurrentUpdate]_block_invoke.1941 + 564
frame #18: 0x00000001071a95bb UIKit`-[UICollectionView _viewAnimationsForCurrentUpdate] + 5141
frame #19: 0x00000001071aebf3 UIKit`__71-[UICollectionView _updateWithItems:tentativelyForReordering:animator:]_block_invoke.2012 + 197
frame #20: 0x000000010691308e UIKit`+[UIView(Animation) performWithoutAnimation:] + 90
frame #21: 0x00000001071ad82d UIKit`-[UICollectionView _updateWithItems:tentativelyForReordering:animator:] + 3856
frame #22: 0x00000001071a7b33 UIKit`-[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:] + 17030
frame #23: 0x00000001071b01cd UIKit`-[UICollectionView _endUpdatesWithInvalidationContext:tentativelyForReordering:animator:] + 71
frame #24: 0x00000001071b0514 UIKit`-[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:] + 437
frame #25: 0x00000001071b033c UIKit`-[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] + 91
frame #26: 0x00000001071b02be UIKit`-[UICollectionView _performBatchUpdates:completion:invalidationContext:] + 74
frame #27: 0x00000001071b0213 UIKit`-[UICollectionView performBatchUpdates:completion:] + 53
* frame #28: 0x00000001046f44be IndexListSampleApp`closure #1 in RemoteIndexListContent.willDisplay(result=success, self=0x00006080000d0fb0, collectionView=0x00007f924588e600, indexPath=2 indices) at RemoteIndexListContent.swift:98
frame #29: 0x00000001046f464d IndexListSampleApp`partial apply for closure #1 in RemoteIndexListContent.willDisplay(itemAtIndexPath:cell:collectionView:) at RemoteIndexListContent.swift:0
frame #30: 0x000000010458f528 IndexListSampleApp`specialized closure #1 in RemoteLiveEventTileContentProvider.loadContent(fixtures=<unavailable>, self=<unavailable>, completion=0x00000001046f45d0 IndexListSampleApp`partial apply forwarder for closure #1 (Result.Result<IndexListFoundation.IndexListContent>) -> () in IndexListFoundation.RemoteIndexListContent.willDisplay(itemAtIndexPath: Foundation.IndexPath, cell: __ObjC.UICollectionViewCell, collectionView: __ObjC.UICollectionView) -> () at RemoteIndexListContent.swift) at RemoteLiveEventTileContentProvider.swift:49 [opt]
frame #31: 0x000000010458cc0b IndexListSampleApp`partial apply for closure #1 in RemoteLiveEventTileContentProvider.loadContent(completion:) [inlined] closure #1 (Swift.Optional<Swift.Array<Core.Fixture>>, Swift.Optional<Swift.Error>) -> () in LiveEvent.RemoteLiveEventTileContentProvider.loadContent(completion: (Result.Result<IndexListFoundation.IndexListContent>) -> ()) -> () at RemoteLiveEventTileContentProvider.swift:0 [opt]
This only happens on iOS 10.2.1 -> 10.3.1 - OK on iOS 9 and iOS 11. I am using Xcode 9.0.1, the crash is also reproducible on Xcode 9.2.
The fix was quite simple. I had "Use Safe Area Layout Guides" ticked - this clearly has an underlying issue on iOS 10.2.1 -> 10.3.1. Unticking this option resolves the crash!

EXC_BAD_ACCESS (code=1, address=0x0)

I have a piece of code which runs correctly in real device but is giving EXC_BAD_ACCESS (code=1, address=0x0) error in simulator (iphone 6) :
The bt output is:
(lldb) bt
* thread #1: tid = 0xe40f6, 0x00000001052ab5e9 CoreFoundation`CFArrayGetCount + 25, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x00000001052ab5e9 CoreFoundation`CFArrayGetCount + 25
* frame #1: 0x0000000104c6a5af MyApp`static MyApp.SSID.fetchSSIDInfo (self=MyApp.SSID)() -> Swift.String + 95 at WifiGetter.swift:17
frame #2: 0x0000000104c4994a MyApp`MyApp.TableViewController.sendWifi (self=0x00007ff05a64da80)() -> () + 26 at TableViewController.swift:355
frame #3: 0x0000000104c49316 MyApp`MyApp.TableViewController.fetchData (self=0x00007ff05a64da80)() -> () + 38 at TableViewController.swift:308
frame #4: 0x0000000104c4567f MyApp`MyApp.TableViewController.viewDidLoad (self=0x00007ff05a64da80)() -> () + 3215 at TableViewController.swift:66
frame #5: 0x0000000104c45ea2 MyApp`#objc MyApp.TableViewController.viewDidLoad (MyApp.TableViewController)() -> () + 34 at TableViewController.swift:0
frame #6: 0x00000001063c9931 UIKit`-[UIViewController loadViewIfRequired] + 1344
frame #7: 0x000000010640cc26 UIKit`-[UINavigationController _layoutViewController:] + 54
frame #8: 0x000000010640d4dd UIKit`-[UINavigationController _updateScrollViewFromViewController:toViewController:] + 433
frame #9: 0x000000010640d633 UIKit`-[UINavigationController _startTransition:fromViewController:toViewController:] + 116
frame #10: 0x000000010640e879 UIKit`-[UINavigationController _startDeferredTransitionIfNeeded:] + 890
frame #11: 0x000000010640f67d UIKit`-[UINavigationController __viewWillLayoutSubviews] + 57
frame #12: 0x00000001065a763d UIKit`-[UILayoutContainerView layoutSubviews] + 248
frame #13: 0x00000001062ef11c UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 710
frame #14: 0x000000010c35836a QuartzCore`-[CALayer layoutSublayers] + 146
frame #15: 0x000000010c34cbd0 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 366
frame #16: 0x000000010c34ca4e QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24
frame #17: 0x000000010c3411d5 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 277
frame #18: 0x000000010c36e9f0 QuartzCore`CA::Transaction::commit() + 508
frame #19: 0x000000010c36f154 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
frame #20: 0x00000001053079d7 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
frame #21: 0x0000000105307947 CoreFoundation`__CFRunLoopDoObservers + 391
frame #22: 0x00000001052fcebc CoreFoundation`CFRunLoopRunSpecific + 524
frame #23: 0x000000010623998d UIKit`-[UIApplication _run] + 402
frame #24: 0x000000010623e676 UIKit`UIApplicationMain + 171
frame #25: 0x0000000104c20efd MyApp`main + 109 at AppDelegate.swift:20
frame #26: 0x0000000108ea592d libdyld.dylib`start + 1
interfaces is nil. You must handle this case. I recommend avoiding !. Making the type non-optional here will allow the if let binding to work correctly.
You should change your if let clause to if let interfaces = CNCopySupportedInterfaces() as? CFArray.
Because you use if let interfaces: CFArray! with ! mean force unwrap, therefore, when CNCopySupportedInterfaces() return nil or value which is not convertible to CFArray, force unwrap will cause crash

iOS App crashes only when attached to the debugger

i have an issue where my app crashes when attached to the debugger in just one case. My App downloads json data and transform it into core data objects. For this purpose i start a background thread to load it and have a successHandler handling the import:
RemoteConnectionService.sharedInstance.sendRequest(UserRequest(userID: user!.webID.integerValue), successHandler: { requestHandler, result in
var userData = result["user"] as! [String: AnyObject]
self.user?.update(userData)
self.tableView.reloadData()
}, errorHandler: nil)
this works everywhere as expected. the successHandler is called on the main thread, core data gets updated and all. but when doing this special request (it happens always and only with this request) Xcode stop pointing to
class AppDelegate: UIResponder, UIApplicationDelegate
with no specific failure reason. here's the backtrace (via bt):
* thread #1: tid = 0x6ab4b, 0x00000001051b19c0 libobjc.A.dylib`objc_release + 16, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x00000001051b19c0 libobjc.A.dylib`objc_release + 16
frame #1: 0x00000001051b28cd libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 591
frame #2: 0x00000001082348d8 CFNetwork`-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 207
frame #3: 0x0000000108234a37 CFNetwork`-[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 48
frame #4: 0x00000001081043a7 CFNetwork`___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 107
frame #5: 0x00000001081d1891 CFNetwork`___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 273
frame #6: 0x00000001080ef6e6 CFNetwork`RunloopBlockContext::_invoke_block(void const*, void*) + 72
frame #7: 0x00000001057c13d4 CoreFoundation`CFArrayApplyFunction + 68
frame #8: 0x00000001080ef5a7 CFNetwork`RunloopBlockContext::perform() + 133
frame #9: 0x00000001080ef3e6 CFNetwork`MultiplexerSource::perform() + 256
frame #10: 0x00000001080ef1fc CFNetwork`MultiplexerSource::_perform(void*) + 72
frame #11: 0x00000001057ee4b1 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
frame #12: 0x00000001057e437d CoreFoundation`__CFRunLoopDoSources0 + 269
frame #13: 0x00000001057e39b4 CoreFoundation`__CFRunLoopRun + 868
frame #14: 0x00000001057e33e6 CoreFoundation`CFRunLoopRunSpecific + 470
frame #15: 0x000000010abdba3e GraphicsServices`GSEventRunModal + 161
frame #16: 0x00000001063cab60 UIKit`UIApplicationMain + 1282
* frame #17: 0x00000001049556b7 App`main + 135 at AppDelegate.swift:13
frame #18: 0x00000001088fd145 libdyld.dylib`start + 1
What i don't get here is that when trying to profile it in instruments or just running it in the simulator without Xcode it works just fine. On the device it crashes on that particular request no matter what.
device backtrace looks a bit different:
* thread #1: tid = 0x19e6ab, 0x0000000192490174 libobjc.A.dylib`objc_release + 20, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x13723bec8)
frame #0: 0x0000000192490174 libobjc.A.dylib`objc_release + 20
frame #1: 0x0000000192491724 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 564
frame #2: 0x00000001817d2e08 CFNetwork`-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 216
frame #3: 0x00000001817d2f7c CFNetwork`-[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 60
frame #4: 0x00000001816a78e4 CFNetwork`___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 104
frame #5: 0x0000000181770540 CFNetwork`___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 104
frame #6: 0x0000000181693b54 CFNetwork`RunloopBlockContext::_invoke_block(void const*, void*) + 76
frame #7: 0x0000000181c10aac CoreFoundation`CFArrayApplyFunction + 68
frame #8: 0x0000000181693a00 CFNetwork`RunloopBlockContext::perform() + 136
frame #9: 0x00000001816938b4 CFNetwork`MultiplexerSource::perform() + 312
frame #10: 0x00000001816936e0 CFNetwork`MultiplexerSource::_perform(void*) + 68
frame #11: 0x0000000181ce69ec CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #12: 0x0000000181ce5c90 CoreFoundation`__CFRunLoopDoSources0 + 264
frame #13: 0x0000000181ce3d40 CoreFoundation`__CFRunLoopRun + 712
frame #14: 0x0000000181c110a4 CoreFoundation`CFRunLoopRunSpecific + 396
frame #15: 0x000000018adab5a4 GraphicsServices`GSEventRunModal + 168
frame #16: 0x0000000186542aa4 UIKit`UIApplicationMain + 1488
* frame #17: 0x0000000100069c8c App`main + 164 at AppDelegate.swift:13
frame #18: 0x0000000192ae6a08 libdyld.dylib`start + 4
Any suggestions on how to debug this? Very much appreciated :)

How to fix MP3AudioStream error?

I'm getting the following error randomly (and sometimes consistently on launch). It can happen when there are background threads and when there aren't and it seems to be a problem with the library so I'm having trouble tracking down the problem in my code. The breakpoint triggers on:
#0 0x07bb489b in MP3AudioStream::GeneratePackets(AudioFileStreamContinuation&) ()
and the backtrace is as follows:
* thread #1: tid = 0x1c03, 0x07bb489b AudioToolbox`MP3AudioStream::GeneratePackets(AudioFileStreamContinuation&) + 2843, stop reason = EXC_BAD_ACCESS (code=2, address=0x4)
frame #0: 0x07bb489b AudioToolbox`MP3AudioStream::GeneratePackets(AudioFileStreamContinuation&) + 2843
frame #1: 0x07b92535 AudioToolbox`AudioFileStreamWrapper::ParseBytes(unsigned long, void const*, unsigned long) + 181
frame #2: 0x07b8f41d AudioToolbox`AudioFileStreamParseBytes + 93
frame #3: 0x07f7a1be MediaToolbox`PushBytesThroughParser + 484
frame #4: 0x07f7a69a MediaToolbox`GetAudioFileStreamPacketAndFrameCount + 221
frame #5: 0x07f7c57e MediaToolbox`FigAudioFileStreamFormatReaderCopyProperty + 225
frame #6: 0x07f9bd1d MediaToolbox`FigPlaybackBossGetDuration + 165
frame #7: 0x07f9f75a MediaToolbox`FigPlaybackBossSetTimeWithRange + 192
frame #8: 0x07f66bef MediaToolbox`itemfig_rebuildRenderPipelinesAndBoss + 10196
frame #9: 0x07f63f01 MediaToolbox`playerfig_prepareWorkingItem2 + 117
frame #10: 0x07f5bdb9 MediaToolbox`playerfig_prepareWorkingItem + 88
frame #11: 0x07f6c536 MediaToolbox`itemfig_assetPropertyBatchLoaded_prepareWorkingItem + 125
frame #12: 0x01bc8758 CoreMedia`figDeferredNotificationRun + 69
frame #13: 0x01de4376 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
frame #14: 0x01de3e06 CoreFoundation`__CFRunLoopDoTimer + 534
frame #15: 0x01dcba82 CoreFoundation`__CFRunLoopRun + 1810
frame #16: 0x01dcaf44 CoreFoundation`CFRunLoopRunSpecific + 276
frame #17: 0x01dcae1b CoreFoundation`CFRunLoopRunInMode + 123
frame #18: 0x02afb7e3 GraphicsServices`GSEventRunModal + 88
frame #19: 0x02afb668 GraphicsServices`GSEventRun + 104
frame #20: 0x00330ffc UIKit`UIApplicationMain + 1211
frame #21: 0x00002a7d FMA`main(argc=1, argv=0xbffff3f0) + 141 at main.m:16
Has anyone had this error and does anyone know how I might go about fixing it?

Resources