My team recently launched an application for which there were quite a few SIGTRAP crashes. Previously, I found that they were relatively easy to fix, since it was about finding a bad strength or an implicitly deployed option set to zero in a violating function. This time, although I can not find anything like it. My best guess is that perhaps one of the TimeBlock objects or its properties is zero due to a calendar error.
Our application is the organizer of a meeting in which the user displays their own iOS calendar events in terms of FreeTime, Conflicts, and Meeting TimeBlocks . I have access to calendars of several users who crashed.
Apple SigTrap Definition
Swift code will exit with this type of exception if an unexpected condition occurs at run time, for example:
- optional type with null value
- failed type conversion
Fault function
func updateTimeHours(timeblocks : [Timeblock]) { for timeblock in timeblocks { switch timeblock { case is MeetingTimeblock: for i in timeblock.startHour...timeblock.endHour { self.meetingHours[i] = true } break case is ConflictTimeblock: for i in timeblock.startHour...timeblock.endHour { self.conflictsHours[i] = true } break default: break } } updateButtonByOffset(offset: self.scrollTimeline.contentOffset.x) }
Call Failure Function
func handleTimeblocksDependantComponents() { buttonLayout() guard Scheduler.sharedInstance.timelines.count > SharedGlobals.Calendar.TODAY_INDEX else { return } updateTimeHours(timeblocks : (Scheduler.sharedInstance.timelines[SharedGlobals.Calendar.TODAY_INDEX].timeblocks)) }
Setheaderheight
private func setHeaderHeight() { self.tableView.tableHeaderView = self.headerView let hostedMeetings = OverviewInteractor.getHostedMeetings(dayIndex: SharedGlobals.Calendar.SELECTED_DAY) let vips = OverviewInteractor.getVIPS(dayIndex: SharedGlobals.Calendar.SELECTED_DAY) self.tableView.beginUpdates() if let headerView = self.tableView.tableHeaderView { var height = 360.0 if(vips.count == 0) { height -= 80.0 } if(hostedMeetings.count == 0) { height -= 80.0 } headerView.frame.size.height = CGFloat(height) } self.tableView.endUpdates() }
TimeBlock Definition
// The Timeblock parent class. It simply holds a start and end time and provides its own duration. Not to be used as such public class Timeblock { public let startTime: Date public let endTime: Date /// Returns the hour the Timeblock starts, in current timezone public var startHour: Int { get { return Calendar.current.component(.hour, from: startTime) } } /// Returns the hour the Timeblocks ends, in current timezone public var endHour: Int { get { return Calendar.current.component(.hour, from: endTime) } } /// Returns the minutes the Timeblocks starts public var startMinutes: Int { get { return Calendar.current.component(.minute, from: startTime) } } /// Returns the minutes the Timeblocks ends public var endMinutes: Int { get { return Calendar.current.component(.minute, from: endTime) } } public init(startTime: Date, endTime: Date) { self.startTime = startTime self.endTime = endTime } @available(iOS 10.0, *) public func getTimeInterval() -> DateInterval { return DateInterval(start: self.startTime, end: self.endTime) } public func getDuration() -> Double { return self.endTime.timeIntervalSince(self.startTime) } }
Crash report
Incident ID: 98D4F477-C57B-4767-B957-E9EA2E0EE3EA CrashReporter Key: 00000000000000000000000000000000000000000000 Hardware Model: undefined Process: xxxxxxx [784] Identifier:
com.xxx.xxx.xx.xxxxxxx Version: 4.0.3 Code type:
arm64
Date / Time: Sun Dec 24 2017 09:55:23 GMT + 0000 (GMT) Start Time: Invalid date OS version: undefined 11.0.3 (15A432) Report version: 105
Exception Type: SIGTRAP Exception Subtype: undefined
Thread 0 name: Thread 0 Crashed: 0 CallIn
0x0000000102c224e4 specialized TimelineHeader.updateTimeHours (timeblocks :) (TimelineHeader.swift: 0) 1 CallIn 0x0000000102c20af0 TimelineHeader.handleTimeblocksDependantComponents () (TimelineHeader.swift: 0) 2 CallIn
0x0000000102c7a28c specialized MeetingTableViewController.tableView (: viewForHeaderInSection :) (TimelineHeader.swift: 78) 3 CallIn
0x0000000102c75d54 @objc MeetingTableViewController.tableView (: viewForHeaderInSection :) (MeetingTableViewController.swift: 0) 4 UIKit
0x000000018d1157d8 - [UITableView _delegateViewForHeaderInSection:] (UIKit) 5 UIKit 0x000000018d11def0 96- [UITableView _sectionHeaderView: withFrame: forSection: floating: reuseViewIfPrivate UitIit (UIT) UIT (UIT) UIT8 (UIKit) UIT8 (UIKit) UIT6 (UIKit) ) 7 UIKit 0x000000018d11dc60 - [UITableView _sectionHeaderView: withFrame : forSection: floating: reuseViewIfPossible: willDisplay:] (UIKit ) 8 UIKit 0x000000018cfc6c04 - [_ UITableViewUpdateSupport (Private ) _setupAnimationsForExistingHeadersAndFooters] (UIKit) 9 UIKit 0x000000018cfc1070 - [_ UITableViewUpdateSupport _setupAnimations] (UIKit) 10 UIKit 0x000000018cfc0944 - [UITableView _updateWithItems: updateSupport:] (UIKit) 11 UIKit 0x000000018cfa8448 - [UITableView endCellAnimationsWithContext:] (UIKit) 12 UIKit 0x000000018cfa46e4ent1e01itUcend01e01t010101c0140101010101010101010101010101010101010101010101010101010101p011 whichent that is used to set up 0x000000018cfa46e02ent01UcIcIt4eUdcTeUtableItem 0x000000018cUcIt4tUpItent () (MeetingTableViewController.swift: 398) 14 CallIn
0x0000000102c7a7c8 specialized closure # 1 in MeetingTableViewController.refreshTable (:) (MeetingTableViewController.swift: 513) 15 CallIn
0x0000000102c7aacc is partially used to close No. 1 in MeetingTableViewController.refreshTable (_ :) (MeetingTableViewController.swift: 0) 16 CallIn
0x0000000102cd17f0 thunk for @callee_owned () β () (LoginPageViewController.swift: 0) 17 libdispatch.dylib
0x000000018327ea54 _dispatch_call_block_and_release (libdispatch.dylib) 18 libdispatch.dylib
0x000000018327ea14 _dispatch_client_callout (libdispatch.dylib) 19 libdispatch.dylib 0x000000018328b698 _dispatch_main_queue_callback_4CF $ VARIANT $ mp ( libdispatch.dylib) 20 CoreFoundation 0x00000001838aa544 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE (CoreFoundation) 21 CoreFoundation 0x00000001838a8120 __CFRunLoopRun (CoreFoundation) 22 CoreFoundation
0x00000001837c7e58 CFRunLoopRunSpecific (CoreFoundation) 23 GraphicsServices 0x0000000185674f84 GSEventRunModal (GraphicsServices) 24 UIKit
0x000000018ce4767c UIApplicationMain (UIKit) 25 CallIn
0x0000000102c02c08 main (AppDelegate.swift: 18) 26 libdyld.dylib
0x00000001832e456c start (libdyld.dylib)