This is a bug in NSURL which managed to astonish me. Even as a seasoned developer you can only but marvel at the easy way to reproduce it and wonder what might be the reason for it happening.
A client reported that our app was crashing. When I launched the app in debugger I expected to see the exception to be something obvious, like a nil being unwrapped. But it turns out that there is a bug in NSLog. Filed as Radar rdar://24406969 and on Open Radar.
Some NSURLs are able to crash an app with EXC_BAD_ACCESS.
Steps to Reproduce
Add the following two lines to a new empty iOS app.
let URL = NSURL(string: "http://files.parsetfss.com/fa80bc63-88d4-412d-a478-2451cffc92a9/tfss-1d2a321d-b02e-4745-a589-e31536f648df-XXXXX%20CAT15%2030.p0001.jpg") NSLog("Loading page with URL: \(URL)")
Run and weep.
The URL should be logged.
The app crashes with EXC_BAD_ACCESS as shown in the attached screen shot
This is the kind of crash that both delights and amuses. 😉
Note: As a workaround I tried absoluteString, but this also causes the crash to occur. Logging scheme, host and path individually seem to work. But better to remove the logging of NSURLs for the time being.
Categories: Bug Reports