Weird SIGTRAP during tableView scroll

Hi!


I hope someone can help me.


A user told me that my app crashes when scrolling a tableView on iOS 13.1.2.

I received the crash log and the error it’s just crazy.


The crash log indicate that the error is at the first line inside the trailingSwipeActionsConfigurationForRowAt method.


override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
     guard items.count > indexPath.row else {return nil} //This line crash.
     …
}

The items property is defined as:

private var items = [AnyObject]()


The error is EXC_BREAKPOINT (SIGTRAP).


How can this line of code crash? items is a non optional variable and indexPath is also a non optional struct.

It's as if indexPath.row was deliberately creating an EXC_BREAKPOINT exception. It is possible?


Another strange thing is that the user say that the app crash during scrolling. It seems that the method trailingSwipeActionsConfigurationForRowAt is called during scroll. That's also strange, it should not be called only when the user does a left swipe? Maybe it has something to do with some accessibility feature because in the call stack of crash report I see some system accessibility methods calls (see crash report below).


Has anyone any ideas that can help me or has encountered a similar problem?


Thank you


Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001de522a94
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [1431]
Triggered by Thread:  0


Thread 0 name:
Thread 0 Crashed:
0   libswiftUIKit.dylib           0x00000001de522a94 $s10Foundation9IndexPathV5UIKitE7sectionSivgTm + 52
1   libswiftUIKit.dylib           0x00000001de522a78 $s10Foundation9IndexPathV5UIKitE7sectionSivgTm + 24
2   MYAPP                       0x000000010219ca4c specialized GroupTableViewController.tableView(_:trailingSwipeActionsConfigurationForRowAt:) + 272 (GroupTableViewController.swift:714)
3   MYAPP                       0x0000000102194544 @objc GroupTableViewController.tableView(_:trailingSwipeActionsConfigurationForRowAt:) + 136 (:0)
4   UIKitCore                     0x00000001ad6ae200 -[UITableView _trailingSwipeConfigurationAtIndexPath:fromRemoveButton:] + 2140 (UITableView.m:16580)
5   UIKit                         0x00000001de7889f0 -[UITableViewCellAccessibility _privateAccessibilityCustomActions] + 544 (UITableViewCellAccessibility.m:3153)
6   UIAccessibility               0x00000001b49e6228 -[NSObject(AXPrivCategory) _retrieveCustomActionsForElement:] + 72 (NSObjectAccessibility.m:2973)
7   UIAccessibility               0x00000001b49e650c -[NSObject(AXPrivCategory) _accessibilityCustomActions] + 260 (NSObjectAccessibility.m:3021)
8   UIAccessibility               0x00000001b49e9978 -[NSObject(AXPrivCategory) _accessibilityCustomActionNamesAndIdentifiers] + 68 (NSObjectAccessibility.m:3683)
9   UIAccessibility               0x00000001b49f07bc -[NSObject(AXPrivCategory) _iosAccessibilityAttributeValue:] + 6580 (NSObjectAccessibility.m:6542)
10  UIAccessibility               0x00000001b49d1d9c _copyMultipleAttributeValuesCallback + 544 (UIAccessibilityRuntime.m:344)
11  AXRuntime                     0x00000001b39fc834 ___AXXMIGCopyMultipleAttributeValues_block_invoke + 64 (AccessibilityPriv.m:1192)
12  AXRuntime                     0x00000001b39fc3a8 _handleNonMainThreadCallback + 68 (AccessibilityPriv.m:467)
13  AXRuntime                     0x00000001b39fc6b8 _AXXMIGCopyMultipleAttributeValues + 304 (AccessibilityPriv.m:1191)
14  AXRuntime                     0x00000001b39f658c _XCopyMultipleAttributeValues + 396 (AccessibilityClientDefsServer.c:1354)
15  AXRuntime                     0x00000001b3a0bd28 mshMIGPerform + 272 (MachServerHelper.c:447)
16  CoreFoundation                 0x00000001a939d91c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60 (CFRunLoop.c:1937)
17  CoreFoundation                 0x00000001a939cfe8 __CFRunLoopDoSource1 + 448 (CFRunLoop.c:2075)
18  CoreFoundation                 0x00000001a9397c20 __CFRunLoopRun + 2144 (CFRunLoop.c:3098)
19  CoreFoundation                 0x00000001a9397098 CFRunLoopRunSpecific + 480 (CFRunLoop.c:3192)
20  GraphicsServices               0x00000001b3501534 GSEventRunModal + 108 (GSEvent.c:2246)
21  UIKitCore                     0x00000001ad4b77ac UIApplicationMain + 1940 (UIApplication.m:4753)
22  MYAPP                       0x000000010209cae8 main + 68 (PlaceViewController.swift:25)
23  libdyld.dylib                 0x00000001a9216f30 start + 4

How did you decide that it was the first line of that method where the crash happened? Are you sure this was line 714 of GroupTableViewController.swift when you built the version of the app that this user has?


The backtrace is showing the error at byte offset 272. That seems kinda big for any machine-level instructions in such a simple line of code. Of course, there may be more going on than is obvious from the limited information shown here.

When attempting to interpret crash reports, it can be helpful to remember they simply point to where the error occured, not the root cause.


In your example, SIGTRAP is not the error, it is the exception. It doesn't show the origin of the crash.


You might need to set break points, walking thru the UI/code so see if you can better id root cause related code block(s).


In the mean time, does your app only support iOS 13.x? Which version Xcode are you using?

The line of code that caused the error was automatically highlighted by Xcode (I received a similar crash report directly into the Xcode organizer crashes section).

Code Block c
int64 fastcall _s10Foundation9IndexPathV5UIKitE7sectionSivgTm(int64 a1)
{
int64 v1; // x0
v1 = _s10Foundation9IndexPathV5countSivg(); // Foundation.IndexPath.count.getter
if ( v1 == 2 )
return _s10Foundation9IndexPathVyS2icig();
__break(1u);
return _s10Foundation9IndexPathV5UIKitE3rowSivpACTK(v1);
}

Code Block swift
struct IndexPath {
  /// The number of elements in the collection.
  ///
  /// To check whether a collection is empty, use its `isEmpty` property
  /// instead of comparing `count` to zero. Unless the collection guarantees
  /// random-access performance, calculating `count` can be an O(*n*)
  /// operation.
  ///
  /// - Complexity: O(1) if the collection conforms to
  ///  `RandomAccessCollection`; otherwise, O(*n*), where *n* is the length
  ///  of the collection.
  public var count: Int { get }
}

Therefore
guard IndexPath.isEmpty == false else { return nil }
Does this solve the problem?
Weird SIGTRAP during tableView scroll
 
 
Q