-
-
Save kommen/1358237 to your computer and use it in GitHub Desktop.
EXC_BAD_ACCESS is _class_getName when throwing NSException with ARC enabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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.