woocommerce-ios icon indicating copy to clipboard operation
woocommerce-ios copied to clipboard

EXC_BREAKPOINT: ProductImagesCollectionViewController.moveProductImageStatus

Open sentry-io[bot] opened this issue 2 years ago • 2 comments

Sentry Issue: WOOCOMMERCE-IOS-1DHF

EXC_BREAKPOINT: release
  File "<compiler-generated>", in range
  File "<compiler-generated>", in Array._checkIndex
  File "<compiler-generated>", in Array.insert
  File "ProductImagesCollectionViewController.swift", line 201, in ProductImagesCollectionViewController.moveProductImageStatus
  File "ProductImagesCollectionViewController.swift", line 211, in ProductImagesCollectionViewController.reorder
...
(25 additional frame(s) were not displayed)

sentry-io[bot] avatar Aug 18 '22 10:08 sentry-io[bot]

I wasn't able to reproduce this one, but in some instances it would seem that the app crashes when calling moveProductImageStatus and attempting to move an image by removing it from an index and insert it in another:

    /// Removes the product image at the given source index and inserts it
    /// at the given destination index.
    ///
    private func moveProductImageStatus(from sourceIndex: Int, to destinationIndex: Int) {
        let imageStatus = productImageStatuses[sourceIndex]
        productImageStatuses.remove(at: sourceIndex)
        productImageStatuses.insert(imageStatus, at: destinationIndex)
    }

Specifically it would seem the failure happens when inserting in destinationIndex, as we get a SIGTRAP signal from the compiler, which could happen because at this point the destinationIndex is either nil or out-of-bounds :

WooCommerce +0x31d8f4 Array._checkIndex (<compiler-generated>)
WooCommerce +0x31d8f4 Array.insert (<compiler-generated>)
WooCommerce +0x31d8f4 ProductImagesCollectionViewController.moveProductImageStatus (ProductImagesCollectionViewController.swift:201)

If is not nil, but outside-of-bounds, we could possibly add a guard check and a [safe:] subscript ro return nil and exist early if needed.

iamgabrielma avatar Aug 18 '22 11:08 iamgabrielma

Impact: low Severity: high = priority medium

joshheald avatar Aug 22 '22 11:08 joshheald