I've added that print, here are the last lines of output before the crash occurred along with the backtrace. This was also with array.reserveCapacity(size) commented out. Also the array size is set to 639 for this example.
i 0 lastElementIndex 13626 size 639 index 207
i 0 lastElementIndex 13627 size 639 index 208
i 1 lastElementIndex 13627 size 639 index 207
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x104690008)
frame #0: 0x000000018bf5c090 libswiftCore.dylib`swift_retain + 60
frame #1: 0x000000018bf9c704 libswiftCore.dylib`swift_bridgeObjectRetain + 56
* frame #2: 0x0000000102671200 RingBufferCrashing`CrossingBuffer.getAfterIndex(refIndex=739167.76999999583, self=0x0000000280b622e0) at CrossingBuffer.swift:55:31
frame #3: 0x000000010266ffb4 RingBufferCrashing`AudioTap.getNext(self=0x0000000282108180) at AudioTap.swift:81:33
frame #4: 0x00000001026701d0 RingBufferCrashing`@objc AudioTap.getNext() at <compiler-generated>:0
Edit: I just added a bit more of the backtrace as I'm wondering whether the compiler-generated:0 is a clue.
Topic:
Programming Languages
SubTopic:
Swift
Tags: