louisdh / openterm

OpenTerm, a sandboxed command line interface for iOS
Other
1.63k stars 249 forks source link

Crash when scrolling InputAssistant and pressing 'U'. #83

Closed asm09fsu closed 6 years ago

asm09fsu commented 6 years ago

Seems that there's a crash happening only when you scroll the InputAssistant and then press 'U' on the US keyboard. I can't seem to see it crash for other letters (didn't try them all), but 'U' is 100% reproducible.

Video link of issue.

It looks like the crash is occurring (I think) in the InputAssistantCollectionView.swift:82

guard let inputAssistantView = inputAssistantView, let name = inputAssistantView.dataSource?.inputAssistantView(inputAssistantView, nameForSuggestionAtIndex: indexPath.row) else {
    fatalError("No suggestion name found at index.")
}

For some reason index 0,0 is initially skipped over, yet once we try to access it, it results in a crash.

(lldb) po indexPath
▿ 2 elements
  - 0 : 0
  - 1 : 1

(lldb) po indexPath
▿ 2 elements
  - 0 : 0
  - 1 : 2

(lldb) po indexPath
▿ 2 elements
  - 0 : 0
  - 1 : 3

(lldb) po indexPath
▿ 2 elements
  - 0 : 0
  - 1 : 4

(lldb) po indexPath
▿ 2 elements
  - 0 : 0
  - 1 : 0

(lldb) po inputAssistantView.dataSource?.inputAssistantView(inputAssistantView, nameForSuggestionAtIndex: indexPath.row)
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x0).
The process has been returned to the state before expression evaluation.

Crash log can be seen below.

2018-02-08 00:22:15.859558-0800 OpenTerm[4870:174896] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndexedSubscript:]: index 9223372036854775806 beyond bounds [0 .. 4]'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010999c12b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x0000000109030f41 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001099dc0cc _CFThrowFormattedException + 194
    3   CoreFoundation                      0x00000001099cd9cf -[__NSArrayM objectAtIndexedSubscript:] + 175
    4   UIKit                               0x000000010b595c52 -[_UIFlowLayoutSection setSize:forItemAtIndexPath:invalidationContext:] + 1486
    5   UIKit                               0x000000010b598f37 -[_UIFlowLayoutInfo setSize:forItemAtIndexPath:] + 417
    6   UIKit                               0x000000010b50cf86 -[UICollectionViewFlowLayout invalidationContextForPreferredLayoutAttributes:withOriginalAttributes:] + 304
    7   UIKit                               0x000000010b4c205a -[UICollectionView _checkForPreferredAttributesInView:originalAttributes:] + 591
    8   UIKit                               0x000000010b4c2b62 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 974
    9   UIKit                               0x000000010b4c278e -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 35
    10  UIKit                               0x000000010b4c7d00 -[UICollectionView _updateVisibleCellsNow:] + 4860
    11  UIKit                               0x000000010b4c9ad8 -[UICollectionView _updateVisibleCellsNow:] + 12500
    12  UIKit                               0x000000010b4c9ad8 -[UICollectionView _updateVisibleCellsNow:] + 12500
    13  UIKit                               0x000000010b4c9ad8 -[UICollectionView _updateVisibleCellsNow:] + 12500
    14  UIKit                               0x000000010b4cdc21 -[UICollectionView layoutSubviews] + 364
    15  UIKit                               0x000000010aac1a6d -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1439
    16  QuartzCore                          0x00000001110c461c -[CALayer layoutSublayers] + 159
    17  QuartzCore                          0x00000001110c87ad _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 401
    18  QuartzCore                          0x000000011104f86c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 364
    19  QuartzCore                          0x000000011107c946 _ZN2CA11Transaction6commitEv + 500
    20  QuartzCore                          0x000000011107d694 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 76
    21  CoreFoundation                      0x000000010993ec07 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    22  CoreFoundation                      0x000000010993eb5e __CFRunLoopDoObservers + 430
    23  CoreFoundation                      0x0000000109923124 __CFRunLoopRun + 1572
    24  CoreFoundation                      0x0000000109922889 CFRunLoopRunSpecific + 409
    25  GraphicsServices                    0x000000011097f9c6 GSEventRunModal + 62
    26  UIKit                               0x000000010a9f05d6 UIApplicationMain + 159
    27  OpenTerm                            0x00000001086a2fe7 main + 55
    28  libdyld.dylib                       0x000000010f391d81 start + 1
    29  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

I can open a ticket on InputAssistant, but since I see @IMcD23 on here, I figure I'd place it here first.

ian-mcdowell commented 6 years ago

Thanks for the bug report. I'm moving discussion for this over to IMcD23/InputAssistant#1.

louisdh commented 6 years ago

Fixed by IMcD23/InputAssistant/pull/2.