XCode 6.3 immediately raises SIGABRT on thrown Obj

2020-06-17 05:20发布

问题:

Consider the following objective-C++ code

- (BOOL)application:(UIApplication *)application
        didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    try
    {
        throw std::logic_error("error message");
    }
    catch (const std::exception& ex)
    {
        NSLog(@"%s", ex.what());
    }
    return YES;
}

In XCode 6.2 it is working as expected ("error message" is logged). However since we upgraded to 6.3, the throwing line (throw std::logic_error...) raises SIGABRT (the stack trace only contains _cxa_throw and _pthread_kill beyond applicationdidFinishLaunchingWithOptions) and crashes the application.

This only happens in our application - when I copy the exact same code to a new project everything works well, even with identical compiler flags.

I've tried specifying -fexceptions and -fnon-call-exceptions to no avail (same behavior).

Update It seems this only happens on 32-bit simulators (it works on actual devices and 64-bit simulators).

Update 2 We narrowed it down to the UserVoice iOS SDK. The behavior is clearly displayed in a new vanilla project simply by linking against it (make sure you call some method so that linkage takes place). We haven't investigated what exactly in that library causes it yet, and we also have some internal libraries that provoke the same behavior (but they should be irrelevant to anyone outside Microsoft).

回答1:

I've found 6.3 to be filled with serious bugs. Upgrading to 6.3.2 seemed to fixed all of my problems. Give that a shot.



回答2:

Apparently this issue was an XCode bug (linker specifically). It was reportedly fixed in XCode 6.4b3. I'm using 6.4 (6E35b) and indeed it seems to have been resolved.