Closed Antonito closed 2 years ago
Not sure if it’s the same bug but we’re also seeing a similar crash on updateOrAppend. Here’s the stacktrace:
#0 0x000000018b16f32c in _swift_runtime_on_report ()
#1 0x000000018b1dfe7c in _swift_stdlib_reportFatalErrorInFile ()
#2 0x000000018aec6aa4 in closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) ()
#3 0x000000018aec6848 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) ()
#4 0x000000018aec61c8 in _assertionFailure(_:_:file:line:flags:) ()
#5 0x000000018aec64bc in _fatalErrorMessage(_:_:file:line:flags:) ()
#6 0x000000018b0db8f8 in UnsafeBufferPointer.subscript.read ()
#7 0x000000018b0db768 in protocol witness for Collection.subscript.read in conformance UnsafeBufferPointer<τ_0_0> ()
#8 0x00000001030fed8c in RandomAccessCollection.subscript.getter at [...]/checkouts/swift-collections/Sources/OrderedCollections/Utilities/RandomAccessCollection+Offsets.swift:28
#9 0x00000001030bca30 in _HashTable.UnsafeHandle._find<τ_0_0>(_:in:) at [...]/checkouts/swift-collections/Sources/OrderedCollections/HashTable/_HashTable+UnsafeHandle.swift:299
#10 0x00000001030fceb0 in closure #1 in closure #1 in OrderedSet._find_inlined(_:) at [...]/checkouts/swift-collections/Sources/OrderedCollections/OrderedSet/OrderedSet.swift:396
#11 0x00000001030fcf14 in thunk for @callee_guaranteed (@unowned _HashTable.UnsafeHandle) -> (@unowned Int?, @unowned _HashTable.Bucket, @error @owned Error) ()
#12 0x00000001030fea20 in partial apply for thunk for @callee_guaranteed (@unowned _HashTable.UnsafeHandle) -> (@unowned Int?, @unowned _HashTable.Bucket, @error @owned Error) ()
#13 0x00000001030c2904 in closure #1 in _HashTable.read<τ_0_0>(_:) at [...]/checkouts/swift-collections/Sources/OrderedCollections/HashTable/_HashTable.swift:151
#14 0x00000001030c2fec in partial apply for closure #1 in _HashTable.read<τ_0_0>(_:) ()
#15 0x000000018afb700c in ManagedBuffer.withUnsafeMutablePointers<τ_0_0>(_:) ()
#16 0x00000001030c2828 in _HashTable.read<τ_0_0>(_:) at [...]/checkouts/swift-collections/Sources/OrderedCollections/HashTable/_HashTable.swift:149
#17 0x00000001030fcd20 in closure #1 in OrderedSet._find_inlined(_:) at [...]/checkouts/swift-collections/Sources/OrderedCollections/OrderedSet/OrderedSet.swift:395
#18 0x00000001030fcfac in thunk for @callee_guaranteed (@unowned UnsafeBufferPointer<τ_0_0>) -> (@unowned Int?, @unowned _HashTable.Bucket, @error @owned Error) ()
#19 0x00000001030fe4b4 in partial apply for thunk for @callee_guaranteed (@unowned UnsafeBufferPointer<τ_0_0>) -> (@unowned Int?, @unowned _HashTable.Bucket, @error @owned Error) ()
#20 0x000000018aea9690 in ContiguousArray.withUnsafeBufferPointer<τ_0_0>(_:) ()
#21 0x00000001030fca4c in OrderedSet._find_inlined(_:) at [...]/checkouts/swift-collections/Sources/OrderedCollections/OrderedSet/OrderedSet.swift:391
#22 0x00000001030fc8bc in OrderedSet._find(_:) at [...]/checkouts/swift-collections/Sources/OrderedCollections/OrderedSet/OrderedSet.swift:385
#23 0x00000001030d9e20 in OrderedDictionary.updateValue(_:forKey:) at [...]/checkouts/swift-collections/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary.swift:541
#24 0x00000001030b22b8 in IdentifiedArray.updateOrAppend(_:) at [...]/checkouts/swift-identified-collections/Sources/IdentifiedCollections/IdentifiedArray/IdentifiedArray+Insertions.swift:67
It crashes reliably on an iOS 15 simulator or an iPhone 6s running iOS 15.0.2 (both debug)
FYI: There's a PR with a fix now: https://github.com/apple/swift-collections/pull/123
Hello,
I'm migrating an app to TCA and experiencing crashes in
IdentifiedArray.subscript.read
during an equality check. Unfortunately I haven't been able to reproduce this case in an isolated example yet.I haven't been able to reproduce the crash in a predictable way with my app either (it seems to appear 'randomly') – but it seems to be triggered by the use
Reducer.debug
.Here is my stack trace:
From what I've been able to debug, at some point
IdentifiedArray.subscript(position:Int)
is called with an invalid position. The_keys
and_values
elements of_dictionary
go out of sync (in my case,_keys
contains 14 elements whereas_dictionary
only contains 13 – which causes an out of range access).For performances reason, one of my TCA state is a
class
, not astruct
, and the crash occurs when its equality is checked. I'm usingIdentifiedArray
in a lot of other places instruct
states and haven't experienced any crash – so this might be related, I guess?Here is a simplified version of my class:
I'm not doing anything fancy with the array, the only methods I'm calling are
updateOrInsert
,update
,append
,sort
– and everything is performed on a single queue.Version
:0.3.1
Xcode 13.0 (release)
Swift 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)
The crash occurs on iOS15.0
&15.1
, I haven't been able to test on MacOS.I'm happy to provide more details if needed – also if this turns out to be a TCA issue, I'll gladly move this issue to its repo.