Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you're seeing is an unfortunate quirk of AppKit and UIKit. Both iOS and OS X have an exception handler in <code>CFRunLoop</code> that traps all uncaught exceptions. On OS X, the handler displays the exception to the user with a dialog box, but on iOS, the handler simply rethrows the exception.</p> <p>Objective-C exceptions, as implemented by <code>NSException</code>, save their backtraces within the exception object right before the actual "throw" happens, as part of <code>[NSException init]</code> (or a similar initializer method). Unfortunately, C++ exceptions don't do the same. Normally, a C++ exception has a backtrace because the runtime library detects that there's no <code>catch</code> and immediately calls <code>std::terminate</code>, which in turn calls <code>abort()</code>, leaving the entire call stack intact, like so:</p> <pre><code>Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x00007fff93ef8d46 __kill + 10 1 libsystem_c.dylib 0x00007fff89968df0 abort + 177 2 libc++abi.dylib 0x00007fff8beb5a17 abort_message + 257 3 libc++abi.dylib 0x00007fff8beb33c6 default_terminate() + 28 4 libobjc.A.dylib 0x00007fff8a196887 _objc_terminate() + 111 5 libc++abi.dylib 0x00007fff8beb33f5 safe_handler_caller(void (*)()) + 8 6 libc++abi.dylib 0x00007fff8beb3450 std::terminate() + 16 7 libc++abi.dylib 0x00007fff8beb45b7 __cxa_throw + 111 8 test 0x0000000102999f3b main + 75 9 libdyld.dylib 0x00007fff8e4ab7e1 start + 1 </code></pre> <p>However, when the run loop exception handler traps the exception, execution resumes normally within the <code>catch</code> block. The original backtrace is therefore lost. The rethrow subsequently calls <code>std::terminate</code>, but at this point, the call stack reflects the run loop exception handler.</p> <p>To get a backtrace from a C++ exception in this circumstance, you have to throw an exception object which mimics <code>NSException</code> and reads the call stack as part of its constructor, and make sure that all exceptions thrown in your code do the same. <code>std::exception</code> doesn't do this, and it's not at all likely that any third-party code you're using will either.</p> <p>File a bug with Apple asking them to remove the <code>CFRunLoop</code> exception handler, or at least provide an API for shutting it off. There is no API, not even an SPI, for doing this right now.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload