0

A unit test that runs normally without problems, crashed now with error EXC_BAD_ACCESS (code=EXC_I386_GPFLT). Here is the relevant stack trace:
enter image description here Obviously an element of an array could not be encoded, maybe because access of a dictionary using its hash value failed. Since this happened in an SQLQueue thread, I suspect that another thread did modify the dictionary during encoding.
The question is how to catch such a problem?

EDIT: I cannot enable the Thread Sanitizer in the scheme, since I have a Watch Extension, and this prevents it.

Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116

1 Answers1

0

Is your question is how to catch the crash? If yes,

for Objective-C, NSSetUncaughtExceptionHandler,

for Swift

signal(SIGABRT, handler)
signal(SIGILL, handler)
signal(SIGSEGV, handler)
signal(SIGFPE, handler)
signal(SIGBUS, handler)
signal(SIGPIPE, handler)

Update: I searched just now, it seems like other guys had discussed it

How to catch a Swift crash and do some logging

J.Hunter
  • 576
  • 4
  • 14
  • Yes, my question is indeed how to catch the error. I guess in my case, I could try `signal(SIGSEGV, handler)`. But what to do in the handler? Set a breakpoint? – Reinhard Männer Jun 08 '19 at 14:33