# EXC\_BREAKPOINT crash with "protocol witness for delegate.\[method\_name\] in conformance"

**URL:** <https://forums.swift.org/t/exc-breakpoint-crash-with-protocol-witness-for-delegate-method-name-in-conformance/28286>\
**Category:** Using Swift\
**Tags:** crash\
**Created:** [August 27, 2019, 4:15pm UTC](https://forums.swift.org/t/exc-breakpoint-crash-with-protocol-witness-for-delegate-method-name-in-conformance/28286 "2019-08-27T16:15:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jml5qh](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@jml5qh](https://forums.swift.org/u/jml5qh)\
**Post date:** [August 27, 2019, 4:15pm UTC](https://forums.swift.org/t/exc-breakpoint-crash-with-protocol-witness-for-delegate-method-name-in-conformance/28286/1 "2019-08-27T16:15:53Z")

</div>

Here is the related code where I get the crash:

```
protocol MixedItemsPerRowFlowLayoutDelegate: NSObjectProtocol {
    typealias TileType = SelfSizingCellProtocol & CellConfigurable

    func tileAtIndexPath(_ indexPath: IndexPath) -> TileType?
    func estimatedItemsPerRow() -> Int
}

class MixedItemsPerRowFlowLayout {
    weak var flowLayoutDelegate: MixedItemsPerRowFlowLayoutDelegate?

   func itemWidth(atIndexPath indexPath: IndexPath?) -> CGFloat {
       if let delegate = self.flowLayoutDelegate, let indexPath = indexPath, let tile = delegate.tileAtIndexPath(indexPath) {
        .....
        }
    }
}

```

This is a UICollectionViewLayout subclass. The MixedItemsPerRowFlowLayoutDelegate is a ViewController. The crash happens on the `tileAtIndexPath` call: protocol witness for MixedItemsPerRowFlowLayoutDelegate.tileAtIndexPath(\_:). in conformance ViewController. Any ideas on what's going on? Unfortunately we're unable to reproduce, but see a bunch of instances in our crash logs.

---

<div class="post-metadata">

**Author:** ![Joe\_Groff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joe_groff/32/1929_2.png) [@Joe\_Groff](https://forums.swift.org/u/Joe_Groff)\
**Post date:** [August 29, 2019, 10:28pm UTC](https://forums.swift.org/t/exc-breakpoint-crash-with-protocol-witness-for-delegate-method-name-in-conformance/28286/2 "2019-08-29T22:28:55Z")

</div>

Is there any integer arithmetic in your implementation that might be overflowing?

---

<div class="post-metadata">

**Author:** ![jml5qh](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@jml5qh](https://forums.swift.org/u/jml5qh)\
**Post date:** [August 29, 2019, 10:41pm UTC](https://forums.swift.org/t/exc-breakpoint-crash-with-protocol-witness-for-delegate-method-name-in-conformance/28286/3 "2019-08-29T22:41:15Z")

</div>

This is the implementation:

```
func tileAtIndexPath(_ indexPath: IndexPath) -> MixedItemsPerRowFlowLayoutDelegate.TileType? {
    return self.viewModel.tiles[indexPath.item]
}

```

Could it be that indexPath.item is out of bounds of the array?

---

<div class="post-metadata">

**Author:** ![Joe\_Groff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joe_groff/32/1929_2.png) [@Joe\_Groff](https://forums.swift.org/u/Joe_Groff)\
**Post date:** [August 29, 2019, 10:45pm UTC](https://forums.swift.org/t/exc-breakpoint-crash-with-protocol-witness-for-delegate-method-name-in-conformance/28286/4 "2019-08-29T22:45:29Z")

</div>

That seems like a likely cause of the trap, yeah.
