[Crash only in release not in debug build]outlined init with copy

Crashed: com.apple.main-thread
EXCBADACCESS KERNINVALIDADDRESS 0x002000000000000

Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x18f1a3be8 objcretain + 8
1 libswiftCore.dylib 0x1bdbaf2dc swift
bridgeObjectRetain + 44
2 AppName 0x1004858b8 initializeWithCopy for ViewProperties.Items + 4307556536 (<compiler-generated>:4307556536)
3 AppName 0x1006ce26c outlined init with copy of ViewProperties.Items + 4309951084
4 AppName 0x1006ccf28 specialized ViewController.collectionView(_:numberOfItemsInSection:)

Could anyone please help what this crash means?
Here ViewProperties is a structure and Items is an enumeration

Replies

In the context of Swift an ‘outlined’ function is the opposite of an inlined one:
  • An inlined function is where the compiler has expanded the function’s implementation at the call site to facilitate optimisations.

  • An outlined function is where the compiler has replaced a sequence of code with a call to a synthesised function in order to reduce code size.

In this case it’s likely that this outlined function is related to your ViewProperties.Items type. That code is trying to retain an object (in the memory management sense) and the retain call has crashed, presumably because the object pointer isn’t valid.

The first thing to do here is run the Debug build of your code under the standard memory debugging tools. This may cause the problem to reproduce with that build.

Share and Enjoy

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