App crashes due to a third-party library we use making a bad memory access.

Is there a way to prevent or handle our application's crash if a third-party library makes a bad memory access? Basically, I want to know if using a buggy library (that causes bad memory access) will automatically make our application inherit those crashes, leading to our app crashing as well. If there is a way to prevent the crash, what methods can be used to do so?

Thread 13: EXC_BAD_ACCESS (code=1, address=0x3a7d300)

Answered by DTS Engineer in 832539022

It depend on the platform. On macOS you can move this code into a separate process and then communicate with that process via some IPC mechanism. For example:

  • You could use an XPC service, and talk to it via XPC.

  • Or a command-line tool that you spawn as a child process, and talk to via pipes.

However, those options are not available on iOS, or any of its child platforms. There are things you can do there, but they are significantly more challenging. For example, if you have source code to the library you could compile it to WebAssembly and run it using an interpreter. But, yeah, that’s a lot of work.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

It depend on the platform. On macOS you can move this code into a separate process and then communicate with that process via some IPC mechanism. For example:

  • You could use an XPC service, and talk to it via XPC.

  • Or a command-line tool that you spawn as a child process, and talk to via pipes.

However, those options are not available on iOS, or any of its child platforms. There are things you can do there, but they are significantly more challenging. For example, if you have source code to the library you could compile it to WebAssembly and run it using an interpreter. But, yeah, that’s a lot of work.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

App crashes due to a third-party library we use making a bad memory access.
 
 
Q