R. Lin R. Lin - 14 days ago 9
Objective-C Question

EXC_BAD_ACCESS only on xcode 8 running iOS 8

The app runs fine when compiled from xcode 7 for iOS 8 through 10 but when compiled from xcode 8, the app only works normally on iOS 9 and 10 on iOS 8, the app crashes inconsistently. Sometimes it will stop at a random UI element such as:

enter image description here

But more often it will just crash at main:

enter image description here

* thread #1: tid = 0x11d655, 0x35deaf56 libobjc.A.dylib`objc_msgSend + 22, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xf632d5c1)
frame #0: 0x35deaf56 libobjc.A.dylib`objc_msgSend + 22
frame #1: 0x2db167ea CoreUI`-[CUINamedImage initWithName:usingRenditionKey:fromTheme:] + 98
frame #2: 0x2db21d48 CoreUI`-[CUICatalog imageWithName:scaleFactor:deviceIdiom:deviceSubtype:sizeClassHorizontal:sizeClassVertical:] + 128
frame #3: 0x2b8aee98 UIKit`__98-[_UIAssetManager imageNamed:scale:idiom:subtype:cachingOptions:sizeClassPair:attachCatalogImage:]_block_invoke + 240
frame #4: 0x2b8aecea UIKit`-[_UIAssetManager imageNamed:scale:idiom:subtype:cachingOptions:sizeClassPair:attachCatalogImage:] + 230
frame #5: 0x2b95df86 UIKit`-[UIImageAsset imageWithTraitCollection:] + 474
frame #6: 0x2b58d9d2 UIKit`-[UIImageView _resolveImageForTrait:] + 286
frame #7: 0x2b58d690 UIKit`-[UIImageView _didMoveFromWindow:toWindow:] + 156
frame #8: 0x2b28aef4 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 656
frame #9: 0x2b300d50 UIKit`-[UIControl _didMoveFromWindow:toWindow:] + 44
frame #10: 0x2b28aef4 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 656
frame #11: 0x2b28aef4 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 656
frame #12: 0x2b28aef4 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 656
frame #13: 0x2b28a804 UIKit`__45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 112
frame #14: 0x2b28a720 UIKit`-[UIView(Hierarchy) _postMovedFromSuperview:] + 428
frame #15: 0x2b294bce UIKit`-[UIView(Internal) _addSubview:positioned:relativeTo:] + 1462
frame #16: 0x2b29460e UIKit`-[UIView(Hierarchy) addSubview:] + 30
frame #17: 0x2b459eae UIKit`__53-[_UINavigationParallaxTransition animateTransition:]_block_invoke + 1262
frame #18: 0x2b29ada4 UIKit`+[UIView(Animation) performWithoutAnimation:] + 72
frame #19: 0x2b45977c UIKit`-[_UINavigationParallaxTransition animateTransition:] + 812
frame #20: 0x2b417cfc UIKit`-[UINavigationController _startCustomTransition:] + 2860
frame #21: 0x2b337026 UIKit`-[UINavigationController _startDeferredTransitionIfNeeded:] + 422
frame #22: 0x2b336e2c UIKit`-[UINavigationController __viewWillLayoutSubviews] + 44
frame #23: 0x2b336dc0 UIKit`-[UILayoutContainerView layoutSubviews] + 184
frame #24: 0x2b28b7fe UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 514
frame #25: 0x2acb1834 QuartzCore`-[CALayer layoutSublayers] + 136
frame #26: 0x2acad20c QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 360
frame #27: 0x2acad094 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
frame #28: 0x2acaca70 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 224
frame #29: 0x2acac874 QuartzCore`CA::Transaction::commit() + 324
frame #30: 0x2aca674c QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 56
frame #31: 0x27d37ffc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
frame #32: 0x27d356ba CoreFoundation`__CFRunLoopDoObservers + 278
frame #33: 0x27d35ac2 CoreFoundation`__CFRunLoopRun + 914
frame #34: 0x27c833b0 CoreFoundation`CFRunLoopRunSpecific + 476
frame #35: 0x27c831c2 CoreFoundation`CFRunLoopRunInMode + 106
frame #36: 0x2f1f2200 GraphicsServices`GSEventRunModal + 136
frame #37: 0x2b2ed43c UIKit`UIApplicationMain + 1440
* frame #38: 0x0017bf62 Dev`main(argc=1, argv=0x01549a28) + 106 at main.m:14
frame #39: 0x3636aaae libdyld.dylib`start + 2


I already have NSZombies enabled and I have gotten no new information. I have also tried turning on the address sanitizer and it will also crash sporadically but usually also at the main method:

enter image description here

thread #1: tid = 0x11d992, 0x020fce9e libclang_rt.asan_ios_dynamic.dylib`__asan::AsanDie(), queue = 'com.apple.main-thread', stop reason = Attempt to free a non-allocated address
{
"access_size" : 0,
"access_type" : 0,
"address" : 103442256,
"description" : "Attempt to free a non-allocated address",
"instrumentation_class" : "AddressSanitizer",
"pc" : 0,
"stop_type" : "fatal_error"
}


Again the app works fine when built from Xcode 7 or from Xcode 8 for iOS 9 or 10. This only happens when built from Xcode 8 for iOS 8. Any ideas?

Answer

Some other guy on the team found the answer. Bogus.

https://forums.developer.apple.com/thread/60919

With Xcode 8 GM, this error will occur if you include 16-bit or P3 assets in an app submission targeting iOS releases earlier then iOS 9.3. If your app requires wide color functionality you must change your Deployment Target to iOS 9.3 or later. If your app does not require wide color functionality and you wish to deploy it to older iOS versions then you should replace all 16-bit or P3 assets with 8-bit sRGB assets. You can find 16-bit or P3 assets by running “assetutil” on the asset catalog named in the error message from iTunes Connect. The following steps outline the process:

  1. Create an Inspectable .ipa file. In the Xcode Organizer (Xcode->Window->Organizer), select an archive to inspect, click “Export...", and choose "Export for Enterprise or Ad-Hoc Deployment". This will create a local copy of the .ipa file for your app.
  2. Locate that .ipa file and change its the extension to .zip.
  3. Expand the .zip file. This will produce a Payload folder containing your .app bundle.
  4. Open a terminal and change the working directory to the top level of your .app bundle cd path/to/Payload/your.app

  5. Use the find tool to locate Assets.car files in your .app bundle as shown below: find . -name 'Assets.car'

  6. Use the assetutil tool to find any 16-bit or P3 assets, in each Assets.car your application has as shown below. : sudo xcrun --sdk iphoneos assetutil --info /path/to/a/Assets.car > /tmp/Assets.json

  7. Examine the resulting /tmp/Assets.json and look for any contents containing “DisplayGamut": “P3” and its associated “Name". This will be the name of your imageset containing one or more 16-bit or P3 assets.

  8. Replace those assets with 8-bit / sRGB assets, then rebuild your app. Update: If your Deployment Target is set to either 8.3 or 8.4 and you have an asset catalog then you will receive this same error message, even if you do not actually have 16-bit or P3 assets. In this case you will either need to lower your Deployment Target to 8.2, or move it up to 9.x.

Update: If your Deployment Target is set to either 8.3 or 8.4 and you have an asset catalog then you will receive this same error message, even if you do not actually have 16-bit or P3 assets. In this case you will either need to lower your Deployment Target to 8.2, or move it up to 9.x.

Comments