'tracking down/working around UnsafeRawBufferPointer with negative count (presumably somewhere out of SwiftUI intestines/Swift runtime)

enter image description here

What do I do about this? I get no useful info predictably. A search for UnsafeMutablePointer yields

 func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {

delegate messages and

private static func bound(_ property: RLMProperty, _ obj: RLMObjectBase) -> UnsafeMutablePointer<LinkingObjects<Element>> {
    return ptr(property, obj).assumingMemoryBound(to: LinkingObjects<Element>.self)
}

in realm. That's it.

Do I hit some Swift runtime shitware paths? Any advice on how to deal with this would be appreciated as I have spent over a day on this manhunt.

UPD manually unrolling ForEach "fixes" the issue

// let baz = Array(zip(data.indices, data))
//            ForEach(baz, id: \.1.id) { index, foo in
            let index = 0
            if let foo = data.first {

reproduces in both Xcode 13.2.1 and 13.3.1



Solution 1:[1]

AFDataResponse was fed with Realm class instead of the Codable struct modelling that incoming instance deserialized from the networking layer and that somehow resulted in this symptom. Gotta love the transparency and resilience of the swift runtime inherited from c++ (that was sarcasm in case you failed to notice)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1