How to debug EXC_BAD_ACCESS KERN_INVALID_ADDRESS crash

We are lately seeing this crash happen randomly to our users. Though the numbers are not high, we still want to address this issue.

Our stack trace is from Crashlytics is:

Code Block
Crashed: com.apple.main-thread
0 CityVideo 0x100698834 specialized HeadlessStateAPI.getParamsForEpisode(_:) + 4302817332 (VideoAPISearchParams.swift:4302817332)
1 CityVideo 0x10068cf64 @objc HeadlessStateAPI.downloadVideosForShow(showInfo:completionBlock:) + 4302770020 (<compiler-generated>:4302770020)
2 CityVideo 0x100637bf4 -[ctvvShowPageViewController2 ctvvReloadData] + 862 (ctvvShowPageViewController2.m:862)
3 CityVideo 0x100632c90 -[ctvvShowPageViewController2 viewDidLoad] + 174 (ctvvShowPageViewController2.m:174)
4 UIKitCore 0x1b5bfa224 -[UIViewController loadViewIfRequired] + 1012
5 UIKitCore 0x1b5bfa628 -[UIViewController view] + 28
6 UIKitCore 0x1b5b57724 -[UINavigationController _startCustomTransition:] + 1072
7 UIKitCore 0x1b5b6b714 -[UINavigationController _startDeferredTransitionIfNeeded:] + 708
8 UIKitCore 0x1b5b6cb3c -[UINavigationController viewWillLayoutSubviews] + 164
9 UIKitCore 0x1b5b4fd4c -[UILayoutContainerView layoutSubviews] + 224
10 UIKitCore 0x1b663b170 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1292
11 QuartzCore 0x18e477c60 -[CALayer layoutSublayers] + 184
12 QuartzCore 0x18e47cc08 CA::Layer::layout_if_needed(CA::Transaction*) + 332
13 QuartzCore 0x18e3df3e4 CA::Context::commit_transaction(CA::Transaction*) + 348
14 QuartzCore 0x18e40d620 CA::Transaction::commit() + 640
15 QuartzCore 0x18e40e15c CA::Transaction::observer_callback(CFRunLoopObserver*, unsigned long, void*) + 92
16 CoreFoundation 0x189ecb4fc CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 32
17 CoreFoundation 0x189ec6224 CFRunLoopDoObservers + 412
18 CoreFoundation 0x189ec67a0 CFRunLoopRun + 1228
19 CoreFoundation 0x189ec5fb4 CFRunLoopRunSpecific + 436
20 GraphicsServices 0x18c0c779c GSEventRunModal + 104
21 UIKitCore 0x1b61a3c38 UIApplicationMain + 212
22 CityVideo 0x10062f8f4 main + 19 (main.m:19)
23 libdyld.dylib 0x1899898e0 start + 4
We use mix of Objc and Swift.


Here is the swift method, that is shown in crash report:

Code Block
@objc
    func downloadVideosForShow(showInfo: ShowsAPI, completionBlock:@escaping(() -> Void)) {
var videos = [VideoAPIVideo]()
        self.downloadVideosViaVIDEOAPI(searchParams: getParamsForEpisode(showInfo)) { results in
            if !results.isEmpty {
                videos.append(contentsOf: results)
            }
            self.downloadVideosViaVIDEOAPI(searchParams: self.getParamsForClips(showInfo)) { results in
                if !results.isEmpty {
                    videos.append(contentsOf: results)
                }
                self.videoData = videos
                completionBlock()
            }
        }
}
func getParamsForEpisode(_ showInfo: ShowsAPI) -> VideoAPISearchParams {
        let searchParameters = VideoAPISearchParams()
        searchParameters.show_id = NSNumber(value: showInfo.showId)
        searchParameters.sort = "%5Eepisode"
        searchParameters.type = .episode
        if let seasons = showInfo.seasons {
            if seasons.count > 1 {
                searchParameters.season = NSNumber(value: showInfo.getChosenSeasonNumber())
            }
        }
        return searchParameters
    }


So far we never able to reproduce this crash on our side.
We tried on both debug and Release build configurations though Xcode.

And zombies instrument didn't catch anything related to this.

We are not sure, if this bug is worth spending more time.

We use the latest Xcode version from App Store.
Do you have any Apple crash reports for this? The crash report you posted shows some weird values (for example, in frame 0 the instruction offset is 4302817332, that is, roughly 4 billion, which is clearly nonsense) which makes me think that perhaps your third-party crash reporter is messing up (1).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"

(1) They are, IMO, not to be trusted.
How to debug EXC_BAD_ACCESS KERN_INVALID_ADDRESS crash
 
 
Q