-
-
Save kommen/1358237 to your computer and use it in GitHub Desktop.
Throwing an exception like this: | |
@throw [NSException exceptionWithName:@"Exception" reason:@"none" userInfo:nil]; | |
in a method, and trying to catch it in a method up the stack, causes a EXC_BAD_ACCESS in: | |
#0 0x36221fd0 in _class_getName () | |
#1 0x36221fbc in object_getClassName () | |
#2 0x362261fe in objc_exception_throw () | |
But only on an iOS device. | |
The exact same code works as expected without a crash on the simulator. | |
Workarounds: | |
* Use CFBridgingRetain() on the exception (shown in the example project) | |
* or store the exception to a local variable first and then throw it | |
Filed as rdar://10330762 |
@tylercollier: It seems the specific bug I have reported to Apple and which the demo exposes was fixed, as it doesn't crash any more for me. It did definitely crash at the time of reporting, I confirmed that with various Xcode/iOS combos back then.
So it seems you're seeing a different, but maybe similar issue?
@kommen, might I have a fixed version of Xcode/iOS now too? My issue was exactly the same as yours. Using [NSException exceptionWithName] would cause EXC_BAD_ACCESS on a device but not the simulator. Using your project, which I modified slightly to run on an iPhone instead of an iPad because I have the former and not the latter, I don't see that issue. And I just reran my project and the EXC_BAD_ACCESS did not happen.
@tylercollier: Yeah, so it looks like Apple fixed that then.
Xcode 4.2.1 build 4D502, iOS 5.0.1 (9A405). I found your post because I was having the same problem with my own app, but your app doesn't produce the same observations. I'm not sure what the difference is.