1

I've got crash report for SIGSEGV. I think it's really not obvious because there are:

  1. No background UI manipulations.
  2. No external CALayer manipulations.
  3. UITableViewCell initialized programmatically, without using xib or storyboard.
  4. No KVO performs on cell properties.

It has occurred only once, so there are no steps to reproduce

Crash log below:

0   libobjc.A.dylib                      0x0000000181d6dbd0 objc_msgSend + 16
1   Foundation                           0x0000000182fc28e4 -[NSObject(NSKeyValueObserverNotification) willChangeValueForKey:] + 320
2   QuartzCore                           0x0000000184ddf374 CA::Layer::set_delegate(objc_object*) + 68
3   UIKit                                0x00000001873e2538 -[UIView _createLayerWithFrame:] + 576
4   UIKit                                0x00000001873e1ff8 UIViewCommonInitWithFrame + 684
5   UIKit                                0x00000001873e1ce8 -[UIView initWithFrame:] + 136
6   UIKit                                0x00000001874c0ee8 -[UITableViewCell initWithStyle:reuseIdentifier:] + 108
7   MyApp                              0x000000010017d208 MyApp.MessageCell.init (MyApp.MessageCell.Type)(style : __C.UITableViewCellStyle, reuseIdentifier : Swift.String?) -> MyApp.MessageCell (MessageCell.swift:23)
8   MyApp                              0x000000010017d340 @objc MyApp.MessageCell.init (MyApp.MessageCell.Type)(style : __C.UITableViewCellStyle, reuseIdentifier : Swift.String?) -> MyApp.MessageCell (MessageCell.swift:0)
9   UIKit                                0x000000018752bbe0 -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 524
10  UIKit                                0x0000000187567bd4 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 84
11  MyApp                              0x000000010016d60c MyApp.ChatDataSource.dequeueMessageCell (MyApp.ChatDataSource)(MyApp.Message, tableView : __ObjC.UITableView, indexPath : __ObjC.NSIndexPath) -> __ObjC.UITableViewCell (ChatDataSource.swift:76)
12  MyApp                              0x000000010016cf48 MyApp.ChatDataSource.cellAtIndexPath (MyApp.ChatDataSource)(__ObjC.NSIndexPath!, inTableView : __ObjC.UITableView!) -> __ObjC.UITableViewCell! (ChatDataSource.swift:55)
13  MyApp                              0x000000010016d324 @objc MyApp.ChatDataSource.cellAtIndexPath (MyApp.ChatDataSource)(__ObjC.NSIndexPath!, inTableView : __ObjC.UITableView!) -> __ObjC.UITableViewCell! (ChatDataSource.swift:0)
14  MyApp                              0x000000010005cb34 -[SFPaginationDataSource tableView:cellForRowAtIndexPath:] (SFPaginationDataSource.m:202)
15  UIKit                                0x000000018773131c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 688
16  UIKit                                0x0000000187731484 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 76
17  UIKit                                0x00000001877207e8 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2356
18  UIKit                                0x0000000187735fb0 -[UITableView _performWithCachedTraitCollection:] + 100
19  UIKit                                0x00000001874cb08c -[UITableView layoutSubviews] + 172
20  UIKit                                0x00000001873db778 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 652
21  QuartzCore                           0x0000000184deab2c -[CALayer layoutSublayers] + 144
22  QuartzCore                           0x0000000184de5738 CA::Layer::layout_if_needed(CA::Transaction*) + 288
23  UIKit                                0x00000001873f2454 -[UIView(Hierarchy) layoutBelowIfNeeded] + 920
24  TextViewController              0x0000000100ec03f4 0x100ea8000 + 99316
25  MyApp                              0x00000001001f5680 MyApp.ChatViewControler.viewWillAppear (MyApp.ChatViewControler)(Swift.Bool) -> () (ChatViewControler.swift:52)
26  MyApp                              0x00000001001f59a4 @objc MyApp.ChatViewControler.viewWillAppear (MyApp.ChatViewControler)(Swift.Bool) -> () (ChatViewControler.swift:0)
27  UIKit                                0x00000001873f874c -[UIViewController _setViewAppearState:isAnimating:] + 624
28  UIKit                                0x00000001873f84c0 -[UIViewController __viewWillAppear:] + 152
29  UIKit                                0x0000000187591ce4 -[UINavigationController _startCustomTransition:] + 1048
30  UIKit                                0x000000018749e9b8 -[UINavigationController _startDeferredTransitionIfNeeded:] + 684
31  UIKit                                0x000000018749e694 -[UINavigationController __viewWillLayoutSubviews] + 56
32  UIKit                                0x000000018749e5fc -[UILayoutContainerView layoutSubviews] + 204
33  UIKit                                0x00000001873db778 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 652
34  QuartzCore                           0x0000000184deab2c -[CALayer layoutSublayers] + 144
35  QuartzCore                           0x0000000184de5738 CA::Layer::layout_if_needed(CA::Transaction*) + 288
36  QuartzCore                           0x0000000184de55f8 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 28
37  QuartzCore                           0x0000000184de4c94 CA::Context::commit_transaction(CA::Transaction*) + 248
38  QuartzCore                           0x0000000184de49dc CA::Transaction::commit() + 508
39  UIKit                                0x00000001873d1c78 _afterCACommitHandler + 176
40  CoreFoundation                       0x00000001826a4588 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28
41  CoreFoundation                       0x00000001826a232c __CFRunLoopDoObservers + 368
42  CoreFoundation                       0x00000001826a275c __CFRunLoopRun + 924
43  CoreFoundation                       0x00000001825d1680 CFRunLoopRunSpecific + 380
44  GraphicsServices                     0x0000000183ae0088 GSEventRunModal + 176
45  UIKit                                0x0000000187448d90 UIApplicationMain + 200
46  MyApp                              0x0000000100199718 main (AppDelegate.swift:17)
47  ???                                  0x00000001821728b8 0x0 + 0

MessageCell.swift

import UIKit

class MessageCell: UITableViewCell, ConfigurableCell {

    var messageView = MessageView()

    var alignment: MessageLayout.MessageAligmment {
        get { return messageView.layout.mode }
        set {
            messageView.layout.mode = newValue
        }
    }

    override required init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        defaultInit()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        defaultInit()
    }

    func defaultInit() {
        selectionStyle = .None
        contentView.addSubview(messageView)
        messageView.autoPinEdgesToSuperviewEdges()
    }

    func configure(item: Message) {
        messageView.configure(item)
    }
}
yariksmirnov
  • 489
  • 5
  • 10
  • Without any code we have no chance of being able to diagnose. What's at line 23 of MessageCell.swift? – Stephen Darlington Dec 21 '15 at 14:38
  • No, problem. I could provide code, but its really straightforward – yariksmirnov Dec 21 '15 at 14:41
  • if it's only ever happened once, and there is no way you can reproduce, it's kind of speculative as to what happened. I'd imagine it has something to do with your SFPaginationDataSource – Louis Tur Dec 21 '15 at 14:42
  • Louis, hm, there is no extra work in SFPaginationDataSource cellForRow.. - it's kind of architecture wrapper around dequeueing and configuring cells. I 've been using it for more than a year, but this crash I face first time – yariksmirnov Dec 21 '15 at 14:50
  • Did you ever solve this problem? I am having a similar crash, also with very simple code. – fishinear Apr 12 '16 at 14:21

1 Answers1

0

"The conclusion that it isn't an invalid KVO observer because it happens during initialization of an object is not correct. For historical reasons, KVO uses a side table to associated object addresses with observers. That means that if the original observee was deallocated, then the next object that occupies that same address is, de facto, the new observee. KVO will act as though the new object is being observed and will try to emit change notifications to possibly-also-deallocated observers." From discussion