Help with crash report

Here are two potentially relevant pieces of the crash report I'm hoping to get some help with:

Crashed Thread:        0

Exception Type:        EXC_BAD_ACCESS (SIGBUS)
Exception Codes:       KERN_PROTECTION_FAILURE at 0x0000000104e8b7d4
Exception Codes:       0x0000000000000002, 0x0000000104e8b7d4

Termination Reason:    Namespace SIGNAL, Code 10 Bus error: 10
Terminating Process:   exc handler [62084]

and

Thread 0 Crashed:
0   libswiftCore.dylib                       0x19b6b4808 swift_retain + 80

What can we know for certain based on the fact that the call to swift_retain was the final step on the crashing thread?

Thanks!

What can we know for certain based on the fact that the call to
swift_retain was the final step on the crashing thread?

It’s hard to know anything for certain, but it’s most likely that you have some sort of memory management problem that’s corrupted stuff to the point that swift_retain ends up being called with a bogus parameter. In cases like this my general advice is that you deploy the standard memory debugging tools to see if you can make the problem more reproducible, and hence fixable.

However, that’s just a guess. I might be able to say more if you posted the full crash report. I have some advice on that front here; just skip the stuff that’s DevForums specific.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like

Thank you for so many leads - I'm happy to know that you share your expertise here on the Swift forum too!

I've only tried to use the memory debugging tools a few times in my life and thus far I've had difficulty getting comprehensible answers about my problems, so before I dive into that I'd like to ask, would the type of memory management problem that you're talking about be possible in a program written purely in the higher levels of Swift? (i.e., no C interop, none of the Unsafe Swift types)

Quite a few things can go wrong even in "high level Swift"

  • unowned variables handling (note, they are not called "Unsafe" (and probably they should be)).
  • stack can still overflow
  • accessing an unprotected data structure (e.g. a dictionary) from two different threads

I'd try diagnostic tools, perhaps one by one or in a combination.
It helps a lot if you have a reproducible crash case.

2 Likes