Terminate / bad_alloc exclusively on iOS 12.

Finally got around to the forum.


libc++abi.dylib

std::__terminate(void (*)()) or std::terminate()

Fatal Exception: std::bad_alloc


std::bad_alloc

// All falls exclusively in the background, for the last month fell about 70 times. All falls displays the Fabric-Crashlytics. If to look at other threads, there are no exceptions and no signs of falling.


Not so long ago, iOS 12 was released for public use, and our application began a massive falls, only on this version (12+). Before that, the application worked for 2 years without such problems.


Crash is clearly not caught, the search for zombie objects also does not give results. The only thing left to think about is that Apple has changed the internal mechanisms of working with memory (???), which throwing the application out of memory, and due to this all models (and old ones including SE, 5s) work 2 times faster, as it was announced at the conference.


I understand that these falls depend directly on the project and its configuration, but still, can you give a push in which direction to dig and look for problems?


All falls exclusively in the background, for the last month fell about 70 times.

Accepted Reply

Another place to look is dynamic types. You could be getting some Objective-C structure from an OS API. Some of the types therein may not be what you expect. Then, if you send a message to one of those objects, "count" or "UTF8String" it could throw an exception if said object doesn't respond to that message. Something like this would be listed in the console log but not in the crash log.


Catching exceptions is not really viable in most cases. You have to find where it is being thrown and don't trigger the code that would cause that.

Replies

Terminate / bad_alloc exclusively on iOS 12.

Do you have an Apple crash report for this problem? If so, please post it. It’s hard to say what’s going on here without more info, and a crash report is the first place to start.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

"Apple Crashes" say about the same, but the number of falls there is an order of magnitude smaller. But also exactly iOS 12.

I understand that everything is very blurry, but I myself do not understand where to look. The only thing I am trying to catch these crashes with the help of zombie objects, but not yet successfully.

And it is strange, why such a difference in the information on the number of crashes? Not all crash reports go to Apple?

If there is something you can help, I will be very grateful!


Exception Type: EXC_CRASH (SIGABRT)

Exception Codes: 0x0000000000000000, 0x0000000000000000

Exception Note: EXC_CORPSE_NOTIFY


Thread 0 Crashed:

0 libsystem_kernel.dylib 0x00000001b97d5104 __pthread_kill + 8

1 libsystem_pthread.dylib 0x00000001b98500e0 pthread_kill$VARIANT$mp + 380 (pthread.c:1468)

2 libsystem_c.dylib 0x00000001b972ce1c __abort + 152 (abort.c:131)

3 libsystem_c.dylib 0x00000001b972cd84 abort + 152 (abort.c:102)

4 libc++abi.dylib 0x00000001b8df4f78 abort_message + 132 (abort_message.cpp:75)

5 libc++abi.dylib 0x00000001b8df5108 default_terminate_handler() + 280 (cxa_default_handlers.cpp:63)

6 libobjc.A.dylib 0x00000001b8e0de58 _objc_terminate() + 140 (objc-exception.mm:696)

7 App_Name 0x0000000102fff5c4 CLSTerminateHandler+ 8353220 () + 328

8 libc++abi.dylib 0x00000001b8e010fc std::__terminate(void (*)()) + 16 (cxa_handlers.cpp:66)

9 libc++abi.dylib 0x00000001b8e01188 std::terminate() + 84 (cxa_handlers.cpp:97)

10 libdispatch.dylib 0x00000001b9678498 _dispatch_client_callout + 36 (object.m:514)

11 libdispatch.dylib 0x00000001b96249ec _dispatch_main_queue_callback_4CF$VARIANT$mp + 1068 (inline_internal.h:2441)

12 CoreFoundation 0x00000001b9bce1bc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1813)

13 CoreFoundation 0x00000001b9bc9084 __CFRunLoopRun + 1964 (CFRunLoop.c:3113)

14 CoreFoundation 0x00000001b9bc85b8 CFRunLoopRunSpecific + 436 (CFRunLoop.c:3247)

15 GraphicsServices 0x00000001bbe3c584 GSEventRunModal + 100 (GSEvent.c:2245)

16 UIKitCore 0x00000001e6b8cbc8 UIApplicationMain + 212 (UIApplication.m:4341)

17 App_Name 0x00000001029a805c main + 1704028 (main.m:8)

18 libdyld.dylib 0x00000001b9688b94 start + 4

iOS 12 has been available to developers since June. This is explicitly what the beta are for. Use them.


As far as your crash goes, it looks like an uncaught exception. That isn’t going to show up directly in the crash log. It might be in the device console log. You will have to review your code for anything that could throw exceptions. I doubt it has anything to do with memory. Looking for zombies isn’t going to help.

Another place to look is dynamic types. You could be getting some Objective-C structure from an OS API. Some of the types therein may not be what you expect. Then, if you send a message to one of those objects, "count" or "UTF8String" it could throw an exception if said object doesn't respond to that message. Something like this would be listed in the console log but not in the crash log.


Catching exceptions is not really viable in most cases. You have to find where it is being thrown and don't trigger the code that would cause that.

Thank you for described where to look.

We now slowly importing project to Swift, and I think the problem will be found soon!

Not all crash reports go to Apple?

Correct. Users have the option to opt out of reporting diagnostics in general, and of reporting them to app developers. This is prominently displayed in the iOS setup assistant, and so many users do indeed opt out.

As john daniel says, the crash report snippet you posted clearly indicates that you crashed because of an unhandled language exception. Such crash reports usually include a Last Exception Backtrace section that can help you isolate the issue. If you post the full crash report I should be able to offer more concrete advice.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi

Last Weeks, we meet the same issue.

All the crash occur in the iOS 12.

The users stay in background for a long time and then crash with C++ Exception.

We catch the Exception:

Application Specific Information: 
Terminating app due to uncaught exception 'std::bad_alloc', reason: 'std::bad_alloc' 
Last Exception Backtrace: 0 libc++abi.dylib std::__terminate 
1 libc++abi.dylib std::terminate 
2 libdispatch.dylib __dispatch_client_callout 
3 libdispatch.dylib __dispatch_main_queue_callback_4CF$VARIANT$armv81 
4 CoreFoundation ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 
5 CoreFoundation ___CFRunLoopRun 6 CoreFoundation _CFRunLoopRunSpecific 
7 GraphicsServices _GSEventRunModal 
8 UIKitCore _UIApplicationMain 
9 OneTravel main main.m:14 
10 libdyld.dylib _start

We think this may connect with obtain location in background,but don't know how to location and fix it.