_scrollViewDidChangeBounds: issue #2126

Closed
dmoagx opened this Issue May 29, 2015 · 30 comments

Projects

None yet

4 participants

@dmoagx
Collaborator
dmoagx commented May 29, 2015

Subjectively speaking the most frequent issue in the recent builds seems to be a crash/exception involving a call to _scrollViewDidChangeBounds: from _postBoundsChangeNotification.

It looks like the underlying issue is a use-after-free because some object did not unregister from a notification before dealloc.

example:

NSInvalidArgumentException

-[_NSViewAuxiliary _scrollViewDidChangeBounds:]: unrecognized selector sent to instance 0x10c588a10

(
    0   CoreFoundation                      0x00007fff8bce003c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff836da76e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8bce30ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff8bc28e24 ___forwarding___ + 1028
    4   CoreFoundation                      0x00007fff8bc28998 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x00007fff8bc9c45c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    6   CoreFoundation                      0x00007fff8bb8c634 _CFXNotificationPost + 3140
    7   Foundation                          0x00007fff91c6d9d1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
    8   AppKit                              0x00007fff8df3f6ba -[NSView _postBoundsChangeNotification] + 186
    9   AppKit                              0x00007fff8df5189a -[NSView translateOriginToPoint:] + 287
    10  AppKit                              0x00007fff8df504bf -[NSClipView _immediateScrollToPoint:] + 3946
    11  AppKit                              0x00007fff8df4f4ae -[NSClipView scrollToPoint:] + 241
    12  AppKit                              0x00007fff8e02f00e -[NSScrollView scrollClipView:toPoint:] + 75
    13  AppKit                              0x00007fff8df4f23d -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:] + 1682
    14  AppKit                              0x00007fff8e18b7a2 -[NSScrollView _doScroller:hitPart:multiplier:] + 1242
    15  AppKit                              0x00007fff8e7a32e0 -[NSScrollingBehaviorLegacy _scrollView:discreetScrollWithEvent:] + 597
    16  AppKit                              0x00007fff8e1891e7 -[NSScrollingBehaviorLegacy scrollView:scrollWheelWithEvent:] + 1642
    17  AppKit                              0x00007fff8df83dfb forwardMethod + 126
    18  AppKit                              0x00007fff8e0b4e00 -[NSView scrollWheel:] + 507
    19  AppKit                              0x00007fff8df83dfb forwardMethod + 126
    20  AppKit                              0x00007fff8e0b4e00 -[NSView scrollWheel:] + 507
    21  AppKit                              0x00007fff8e5fa6ec -[NSWindow _reallySendEvent:isDelayedEvent:] + 6941
    22  AppKit                              0x00007fff8df8bd76 -[NSWindow sendEvent:] + 470
    23  Sequel Pro                          0x000000010012ca37 Sequel Pro + 1231415
    24  AppKit                              0x00007fff8df88237 -[NSApplication sendEvent:] + 2285
    25  AppKit                              0x00007fff8deb1c68 -[NSApplication run] + 711
    26  AppKit                              0x00007fff8de2e354 NSApplicationMain + 1832
    27  Sequel Pro                          0x0000000100001d84 Sequel Pro + 7556
)

Most of them are (erroneously) grouped with:
http://log.sequelpro.com/view/3622
http://log.sequelpro.com/view/4400
and (correctly grouped)
http://log.sequelpro.com/view/5050
http://log.sequelpro.com/view/5124
http://log.sequelpro.com/view/4725

The issue only ever happened once with 1.0.2M (4135), so I guess it's safe to say it was introduced afterwards.
Next occurrence was with nb 4236. Highest amount was with 4262.

Summary so far

  • Opening a new tab/window is a pretty popular trigger for this issue. There are other causes, too…
  • The dealloc'd object (observer) in all cases was a SPTableView (or its child SPCopyTable)
  • The notification sender is always a NSClipView
  • The issue is more popular under 10.10/10.11 than 10.9 (though that could be related to general OS popularity)
  • All stack traces show -[NSTableView setLayer:] as the method adding the observer. It actually happens in -[NSTableView _startObservingViewDidScroll] (which is called by setLayer:), resp. -[NSTableView _stopObservingViewDidScroll]
  • The timing of events (start observing / dealloc / call & crash) is not necessarily closely related (ie. even if SP crashes on opening a new tab, the over-released object could have been sitting in another tab for some time already).
@dmoagx dmoagx added the Bug label May 29, 2015
@dmoagx
Collaborator
dmoagx commented Aug 22, 2015

Perhaps we should include Google's Zombie implementation to get closer to the cause:
https://chromium.googlesource.com/chromium/src/+/master/chrome/common/mac/objc_zombie.mm

@dmoagx
Collaborator
dmoagx commented Aug 29, 2015

Here are some recent reports:

NSInternalInconsistencyException

-[NSObject(SPObjectAdditions) _scrollViewDidChangeBounds:] tripped!

passed object (class <NSConcreteNotification>): NSConcreteNotification 0x121870390 {name = NSViewBoundsDidChangeNotification; object = <NSClipView: 0x119211b40>}

unwrapping NSNotification named 'NSViewBoundsDidChangeNotification' (userInfo=(null))

passed object (class <NSClipView>): <NSClipView: 0x119211b40>

View hierarchy (parents):
- 0x119211b40 (class <NSClipView>): <NSClipView: 0x119211b40>, id=_NS:37, tag=-1
- 0x1229b85c0 (class <NSScrollView>): <NSScrollView: 0x1229b85c0>, id=_NS:44, tag=-1
- 0x10eabc670 (class <NSView>): <NSView: 0x10eabc670>, id=_NS:10, tag=-1

View hierarchy (own children): 
- 0x1218193b0 (class <NSTableView>): <NSTableView: 0x1218193b0>, id=_NS:36, tag=0

In Window: (null)

self: 0x10ce20520 (class <_NSViewAuxiliary>)



(
    0   CoreFoundation                      0x00007fff992ffa22 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff916ab73c objc_exception_throw + 48
    2   Sequel Pro                          0x0000000100132f98 -[SPDatabaseStructure init] + 0
    3   CoreFoundation                      0x00007fff992b96bc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    4   CoreFoundation                      0x00007fff992b962f ___CFXRegistrationPost_block_invoke + 63
    5   CoreFoundation                      0x00007fff992b8cf7 _CFXRegistrationPost + 407
    6   CoreFoundation                      0x00007fff992b8a62 ___CFXNotificationPost_block_invoke + 50
    7   CoreFoundation                      0x00007fff992b2cf2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1922
    8   CoreFoundation                      0x00007fff991a1845 _CFXNotificationPost + 693
    9   Foundation                          0x00007fff8e8068d1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
    10  AppKit                              0x00007fff97940da1 -[NSView _postBoundsChangeNotification] + 175
    11  AppKit                              0x00007fff979528b6 -[NSView translateOriginToPoint:] + 287
    12  AppKit                              0x00007fff97950c4d -[NSClipView _immediateScrollToPoint:] + 1277
    13  AppKit                              0x00007fff979506a8 -[NSClipView scrollToPoint:] + 241
    14  AppKit                              0x00007fff97a24b18 -[NSScrollView scrollClipView:toPoint:] + 75
    15  AppKit                              0x00007fff97950453 -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:] + 1692
    16  AppKit                              0x00007fff9794fbe1 -[NSClipView _reflectDocumentViewFrameChange] + 128
    17  AppKit                              0x00007fff979381ef -[NSClipView setContentInsets:] + 380
    18  AppKit                              0x00007fff97936b39 -[NSScrollView _applyContentAreaLayout:] + 1001
    19  AppKit                              0x00007fff97935605 -[NSScrollView tile] + 2761
    20  AppKit                              0x00007fff97934ab3 -[NSScrollView _tileWithoutRecursing] + 51
    21  AppKit                              0x00007fff97939109 -[NSScrollView reflectScrolledClipView:] + 1030
    22  AppKit                              0x00007fff97937eff -[NSClipView _selfBoundsChanged] + 815
    23  AppKit                              0x00007fff9793ba9b -[NSClipView setBoundsOrigin:] + 59
    24  AppKit                              0x00007fff9793b5bb -[NSClipView setDocumentView:] + 700
    25  AppKit                              0x00007fff9793ae6b -[NSScrollView setDocumentView:] + 113
    26  AppKit                              0x00007fff97862a20 -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 368
    27  AppKit                              0x00007fff978419c1 loadNib + 384
    28  AppKit                              0x00007fff97840ee5 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 300
    29  AppKit                              0x00007fff979df7d0 +[NSBundle(NSNibLoadingInternal) _loadNibFile:externalNameTable:options:withZone:] + 150
    30  AppKit                              0x00007fff979df588 -[NSWindowController loadWindow] + 310
    31  AppKit                              0x00007fff979da9f3 -[NSWindowController window] + 80
    32  Sequel Pro                          0x00000001000bb9c0 -[SPUserManager beginSheetModalForWindow:completionHandler:] + 70
    33  Sequel Pro                          0x0000000100036822 -[SPDatabaseDocument showUserManager:] + 301
    34  Sequel Pro                          0x00000001000f4c9f -[SPWindowController performSelector:withObject:] + 172
    35  libsystem_trace.dylib               0x00007fff9890c082 _os_activity_initiate + 75
    36  AppKit                              0x00007fff97a70685 -[NSApplication sendAction:to:from:] + 460
    37  AppKit                              0x00007fff97a7041f -[NSMenuItem _corePerformAction] + 336
    38  AppKit                              0x00007fff97a7017f -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 114
    39  libsystem_trace.dylib               0x00007fff9890c082 _os_activity_initiate + 75
    40  AppKit                              0x00007fff97b303a4 -[NSMenu performActionForItemAtIndex:] + 131
    41  AppKit                              0x00007fff97b30317 -[NSMenu _internalPerformActionForItemAtIndex:] + 35
    42  AppKit                              0x00007fff97b3016f -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 107
    43  AppKit                              0x00007fff97a59025 NSSLMMenuEventHandler + 708
    44  HIToolbox                           0x00007fff887e98da _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1231
    45  HIToolbox                           0x00007fff887e8d64 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 404
    46  HIToolbox                           0x00007fff887fdeaa SendEventToEventTarget + 40
    47  HIToolbox                           0x00007fff88836d36 _ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 411
    48  HIToolbox                           0x00007fff88871da3 SendMenuCommandWithContextAndModifiers + 59
    49  HIToolbox                           0x00007fff88871d54 SendMenuItemSelectedEvent + 188
    50  HIToolbox                           0x00007fff88871c30 _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 96
    51  HIToolbox                           0x00007fff8887264c _ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 711
    52  HIToolbox                           0x00007fff888722e4 _HandleMenuSelection2 + 460
    53  AppKit                              0x00007fff979837ce _NSHandleCarbonMenuEvent + 277
    54  AppKit                              0x00007fff978c3552 _DPSNextEvent + 1951
    55  AppKit                              0x00007fff97c8f90d -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
    56  AppKit                              0x00007fff978b90b8 -[NSApplication run] + 682
    57  AppKit                              0x00007fff9783b396 NSApplicationMain + 1176
    58  Sequel Pro                          0x0000000100001714 start + 52
)
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[NSObject(SPObjectAdditions) _scrollViewDidChangeBounds:] tripped!

passed object (class <NSConcreteNotification>): NSConcreteNotification 0x608000059c80 {name = NSViewBoundsDidChangeNotification; object = <NSClipView: 0x100855950>}

unwrapping NSNotification named 'NSViewBoundsDidChangeNotification' (userInfo=(null))

passed object (class <NSClipView>): <NSClipView: 0x100855950>

View hierarchy (parents):
- 0x100855950 (class <NSClipView>): <NSClipView: 0x100855950>, id=_NS:850, tag=-1
- 0x6100001c3480 (class <NSScrollView>): <NSScrollView: 0x6100001c3480>, id=_NS:848, tag=-1
- 0x610000124380 (class <NSView>): <NSView: 0x610000124380>, id=_NS:846, tag=-1
- 0x6100001ea300 (class <SPSplitView>): <SPSplitView: 0x6100001ea300>, id=_NS:843, tag=-1
- 0x610000122f80 (class <NSView>): <NSView: 0x610000122f80>, id=_NS:841, tag=-1
- 0x6100001ea200 (class <SPSplitView>): <SPSplitView: 0x6100001ea200>, id=_NS:838, tag=-1
- 0x610000123660 (class <NSView>): <NSView: 0x610000123660>, id=QueryTabView, tag=-1
- 0x10084cb90 (class <NSTabView>): <NSTabView: 0x10084cb90>, id=_NS:327, tag=-1
- 0x610000121d60 (class <NSView>): <NSView: 0x610000121d60>, id=MainAreaSplitPane, tag=-1
- 0x6100001e5300 (class <SPSplitView>): <SPSplitView: 0x6100001e5300>, id=_NS:58, tag=-1
- 0x6180001288e0 (class <NSView>): <NSView: 0x6180001288e0>, id=MasterDBView, tag=-1
- 0x100858160 (class <NSTabView>): <NSTabView: 0x100858160>, id=_NS:17, tag=-1
- 0x610000125c80 (class <NSView>): <NSView: 0x610000125c80>, id=_NS:10, tag=-1
- 0x10084ac00 (class <NSThemeFrame>): <NSThemeFrame: 0x10084ac00>, id=(null), tag=-1

View hierarchy (own children): 
- 0x600000123de0 (class <_NSClipViewOverhangView>): <_NSClipViewOverhangView: 0x600000123de0>, id=(null), tag=-1
- 0x600000124560 (class <_NSClipViewOverhangView>): <_NSClipViewOverhangView: 0x600000124560>, id=(null), tag=-1
- 0x10110da00 (class <SPTextView>): <SPTextView: 0x10110da00>
    Frame = {{0.00, 0.00}, {1102.00, 272.00}}, Bounds = {{0.00, 0.00}, {1102.00, 272.00}}
    Horizontally resizable: YES, Vertically resizable: YES
    MinSize = {1102.00, 272.00}, MaxSize = {100000.00, 10000000.00}
, id=_NS:852, tag=-1

In Window: <SPWindow: 0x10083d5d0>

self: 0x10081d400 (class <_NSViewAuxiliary>)

'
abort() called
terminating with uncaught exception of type NSException

Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fff96e4603c __exceptionPreprocess + 172
1   libobjc.A.dylib                     0x00007fff92dc976e objc_exception_throw + 43
2   Sequel Pro                          0x0000000100132f98 -[SPDatabaseStructure init] + 0
3   CoreFoundation                      0x00007fff96e0245c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
4   CoreFoundation                      0x00007fff96cf2634 _CFXNotificationPost + 3140
5   Foundation                          0x00007fff8ef34aa1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
6   AppKit                              0x00007fff961ca5aa -[NSView _postBoundsChangeNotification] + 186
7   AppKit                              0x00007fff961dc78a -[NSView translateOriginToPoint:] + 287
8   AppKit                              0x00007fff961dac24 -[NSClipView _immediateScrollToPoint:] + 2015
9   AppKit                              0x00007fff961da39e -[NSClipView scrollToPoint:] + 241
10  AppKit                              0x00007fff962b9f0e -[NSScrollView scrollClipView:toPoint:] + 75
11  AppKit                              0x00007fff961da12d -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:] + 1682
12  AppKit                              0x00007fff9634ac39 -[_NSScrollingConcurrentMainThreadSynchronizer _scrollToCononicalOrigin] + 1064
13  AppKit                              0x00007fff9634a481 -[_NSScrollingConcurrentMainThreadSynchronizer _synchronize:completionHandler:] + 167
14  AppKit                              0x00007fff9634a393 __80-[_NSScrollingConcurrentMainThreadSynchronizer initWithSharedData:constantData:]_block_invoke + 144
15  libdispatch.dylib                   0x00007fff9457bc13 _dispatch_client_callout + 8
16  libdispatch.dylib                   0x00007fff9458687e _dispatch_source_latch_and_call + 721
17  libdispatch.dylib                   0x00007fff9457f62b _dispatch_source_invoke + 412
18  libdispatch.dylib                   0x00007fff94587b02 _dispatch_main_queue_callback_4CF + 416
19  CoreFoundation                      0x00007fff96d993f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
20  CoreFoundation                      0x00007fff96d5468f __CFRunLoopRun + 2159
21  CoreFoundation                      0x00007fff96d53bd8 CFRunLoopRunSpecific + 296
22  HIToolbox                           0x00007fff8ec5956f RunCurrentEventLoopInMode + 235
23  HIToolbox                           0x00007fff8ec592ea ReceiveNextEventCommon + 431
24  HIToolbox                           0x00007fff8ec5912b _BlockUntilNextEventMatchingListInModeWithFilter + 71
25  AppKit                              0x00007fff961478ab _DPSNextEvent + 978
26  AppKit                              0x00007fff96146e58 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346
27  AppKit                              0x00007fff9613caf3 -[NSApplication run] + 594
28  AppKit                              0x00007fff960b9244 NSApplicationMain + 1832
29  Sequel Pro                          0x00000001000016a4 start + 52
30  ???                                 0x0000000000000001 0x0 + 1
NSInternalInconsistencyException

-[NSObject(SPObjectAdditions) _scrollViewDidChangeBounds:] tripped!

passed object (class <NSConcreteNotification>): NSConcreteNotification 0x10b2caca0 {name = NSViewBoundsDidChangeNotification; object = <NSClipView: 0x112c3c480>}

unwrapping NSNotification named 'NSViewBoundsDidChangeNotification' (userInfo=(null))

passed object (class <NSClipView>): <NSClipView: 0x112c3c480>

View hierarchy (parents):
- 0x112c3c480 (class <NSClipView>): <NSClipView: 0x112c3c480>, id=_NS:1492, tag=-1
- 0x114d56bf0 (class <NSScrollView>): <NSScrollView: 0x114d56bf0>, id=_NS:1490, tag=-1
- 0x114d84c10 (class <NSView>): <NSView: 0x114d84c10>, id=TriggersTabView, tag=-1

View hierarchy (own children): 
- 0x112c76660 (class <SPCopyTable>): <SPCopyTable: 0x112c76660>, id=_NS:1494, tag=0

In Window: (null)

self: 0x114ddac10 (class <NSButtonCell>)



(
    0   CoreFoundation                      0x00007fff900fb7dc __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff9658e810 objc_exception_throw + 48
    2   Sequel Pro                          0x0000000100132f98 -[SPDatabaseStructure init] + 0
    3   CoreFoundation                      0x00007fff900b55dc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    4   CoreFoundation                      0x00007fff900b554f ___CFXRegistrationPost_block_invoke + 63
    5   CoreFoundation                      0x00007fff900b4c17 _CFXRegistrationPost + 407
    6   CoreFoundation                      0x00007fff900b4982 ___CFXNotificationPost_block_invoke + 50
    7   CoreFoundation                      0x00007fff900ae842 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1922
    8   CoreFoundation                      0x00007fff8ff9d9a5 _CFXNotificationPost + 693
    9   Foundation                          0x00007fff8a229133 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
    10  AppKit                              0x00007fff94d0af6c -[NSView _postBoundsChangeNotification] + 175
    11  AppKit                              0x00007fff94d1ca6a -[NSView translateOriginToPoint:] + 287
    12  AppKit                              0x00007fff94d1ae02 -[NSClipView _immediateScrollToPoint:] + 1277
    13  AppKit                              0x00007fff94d1a85d -[NSClipView scrollToPoint:] + 241
    14  AppKit                              0x00007fff94def2d0 -[NSScrollView scrollClipView:toPoint:] + 75
    15  AppKit                              0x00007fff94d1a601 -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:] + 1698
    16  AppKit                              0x00007fff94d19d89 -[NSClipView _reflectDocumentViewFrameChange] + 128
    17  AppKit                              0x00007fff94d023bb -[NSClipView setContentInsets:] + 380
    18  AppKit                              0x00007fff94d00d05 -[NSScrollView _applyContentAreaLayout:] + 1001
    19  AppKit                              0x00007fff94cff7d1 -[NSScrollView tile] + 2761
    20  AppKit                              0x00007fff94cfec7f -[NSScrollView _tileWithoutRecursing] + 51
    21  AppKit                              0x00007fff94d032d1 -[NSScrollView reflectScrolledClipView:] + 1030
    22  AppKit                              0x00007fff94d020cb -[NSClipView _selfBoundsChanged] + 815
    23  AppKit                              0x00007fff94d05c67 -[NSClipView setBoundsOrigin:] + 59
    24  AppKit                              0x00007fff94d05787 -[NSClipView setDocumentView:] + 700
    25  AppKit                              0x00007fff94d05037 -[NSScrollView setDocumentView:] + 113
    26  AppKit                              0x00007fff94c2d45d -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 368
    27  AppKit                              0x00007fff94df10da -[NSNib _instantiateNibWithExternalNameTable:options:] + 677
    28  AppKit                              0x00007fff94fa5b30 -[NSNib instantiateNibWithOwner:topLevelObjects:] + 212
    29  Sequel Pro                          0x000000010002e53a -[SPDatabaseDocument init] + 1178
    30  Sequel Pro                          0x00000001000f3c65 -[SPWindowController addNewConnection:] + 60
    31  Sequel Pro                          0x0000000100145296 -[SPAppController(SPWindowManagement) newTab:] + 441
    32  libsystem_trace.dylib               0x00007fff95e24082 _os_activity_initiate + 75
    33  AppKit                              0x00007fff94e3ad8d -[NSApplication sendAction:to:from:] + 460
    34  AppKit                              0x00007fff94e3ab27 -[NSMenuItem _corePerformAction] + 336
    35  AppKit                              0x00007fff94e3a887 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 114
    36  libsystem_trace.dylib               0x00007fff95e24082 _os_activity_initiate + 75
    37  AppKit                              0x00007fff94e39775 -[NSMenu performKeyEquivalent:] + 357
    38  AppKit                              0x00007fff94e3891b -[NSApplication _handleKeyEquivalent:] + 920
    39  AppKit                              0x00007fff94d50a42 -[NSApplication sendEvent:] + 4274
    40  AppKit                              0x00007fff94c839f8 -[NSApplication run] + 796
    41  AppKit                              0x00007fff94c05e9a NSApplicationMain + 1176
    42  Sequel Pro                          0x00000001000016f4 start + 52
)
NSInternalInconsistencyException

-[NSObject(SPObjectAdditions) _scrollViewDidChangeBounds:] tripped!

passed object (class <NSConcreteNotification>): NSConcreteNotification 0x608000443330 {name = NSViewBoundsDidChangeNotification; object = <NSClipView: 0x1008c2930>}

unwrapping NSNotification named 'NSViewBoundsDidChangeNotification' (userInfo=(null))

passed object (class <NSClipView>): <NSClipView: 0x1008c2930>

View hierarchy (parents):
- 0x1008c2930 (class <NSClipView>): <NSClipView: 0x1008c2930>, id=_NS:539, tag=-1
- 0x6080001c7ad0 (class <NSScrollView>): <NSScrollView: 0x6080001c7ad0>, id=TableStructureIndexesTableScrollView, tag=-1
- 0x600000327bc0 (class <NSView>): <NSView: 0x600000327bc0>, id=TableStructureIndexesView, tag=-1
- 0x608000328de0 (class <NSSplitView>): <NSSplitView: 0x608000328de0>, id=_NS:331, tag=-1
- 0x608000134fa0 (class <NSView>): <NSView: 0x608000134fa0>, id=StructureTabView, tag=-1
- 0x1165cc370 (class <NSTabView>): <NSTabView: 0x1165cc370>, id=_NS:327, tag=-1
- 0x60800013b300 (class <NSView>): <NSView: 0x60800013b300>, id=MainAreaSplitPane, tag=-1
- 0x6080003f5900 (class <SPSplitView>): <SPSplitView: 0x6080003f5900>, id=_NS:58, tag=-1
- 0x60800012faa0 (class <NSView>): <NSView: 0x60800012faa0>, id=MasterDBView, tag=-1
- 0x110558cf0 (class <NSTabView>): <NSTabView: 0x110558cf0>, id=_NS:17, tag=-1
- 0x600000123b60 (class <NSView>): <NSView: 0x600000123b60>, id=_NS:10, tag=-1
- 0x1170c9290 (class <NSThemeFrame>): <NSThemeFrame: 0x1170c9290>, id=(null), tag=-1

View hierarchy (own children): 
- 0x1008cb360 (class <SPTableView>): <SPTableView: 0x1008cb360>, id=TableStructureIndexesTableView, tag=0

In Window: <SPWindow: 0x117013070>

self: 0x11657c400 (class <NSClipView>)



(
    0   CoreFoundation                      0x00007fff8c90003c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff964ad76e objc_exception_throw + 43
    2   Sequel Pro                          0x0000000100132f98 -[SPDatabaseStructure init] + 0
    3   CoreFoundation                      0x00007fff8c8bc45c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    4   CoreFoundation                      0x00007fff8c7ac634 _CFXNotificationPost + 3140
    5   Foundation                          0x00007fff93a2faa1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
    6   AppKit                              0x00007fff8b7155aa -[NSView _postBoundsChangeNotification] + 186
    7   AppKit                              0x00007fff8b710326 -[NSView setBoundsOrigin:] + 279
    8   AppKit                              0x00007fff8b7101f3 -[NSClipView setBoundsOrigin:] + 43
    9   AppKit                              0x00007fff8b714777 -[NSView setBounds:] + 197
    10  AppKit                              0x00007fff8b7162eb -[NSScrollView viewDidChangeBackingProperties] + 166
    11  AppKit                              0x00007fff8b64b606 _NSViewHierarchyDidChangeBackingProperties + 344
    12  AppKit                              0x00007fff8b6400e5 -[NSView addSubview:] + 1313
    13  AppKit                              0x00007fff8b7e8c95 -[NSTabView _switchTabViewItem:oldView:withTabViewItem:newView:initialFirstResponder:lastKeyView:] + 377
    14  AppKit                              0x00007fff8b7e866b -[NSTabView selectTabViewItem:] + 530
    15  AppKit                              0x00007fff8b7e82ec -[NSTabView _addedTab:atIndex:] + 150
    16  Sequel Pro                          0x00000001000f3d0c -[SPWindowController addNewConnection:] + 227
    17  Sequel Pro                          0x0000000100145069 -[SPAppController(SPWindowManagement) newWindow:] + 214
    18  libsystem_trace.dylib               0x00007fff8f755cd7 _os_activity_initiate + 75
    19  AppKit                              0x00007fff8b855eb1 -[NSApplication sendAction:to:from:] + 452
    20  AppKit                              0x00007fff8b855c4e -[NSMenuItem _corePerformAction] + 382
    21  AppKit                              0x00007fff8b85597c -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 114
    22  libsystem_trace.dylib               0x00007fff8f755cd7 _os_activity_initiate + 75
    23  AppKit                              0x00007fff8b8548ad -[NSMenu performKeyEquivalent:] + 359
    24  AppKit                              0x00007fff8b853a6f -[NSApplication _handleKeyEquivalent:] + 920
    25  AppKit                              0x00007fff8b75e83a -[NSApplication sendEvent:] + 4080
    26  AppKit                              0x00007fff8b687b68 -[NSApplication run] + 711
    27  AppKit                              0x00007fff8b604244 NSApplicationMain + 1832
    28  Sequel Pro                          0x00000001000016a4 start + 52
)

So it's not limited to a single table view, but happens across the whole app.

@dmoagx
Collaborator
dmoagx commented Sep 15, 2015

So we now have a full lifecycle trace:

NSInternalInconsistencyException

-[NSObject(SPObjectAdditions) _scrollViewDidChangeBounds:] tripped!

passed object (class <NSConcreteNotification>): NSConcreteNotification 0x10ff0dac0 {name = NSViewBoundsDidChangeNotification; object = <NSClipView: 0x1095dd340>}

unwrapping NSNotification named 'NSViewBoundsDidChangeNotification' (userInfo=(null))

passed object (class <NSClipView>): <NSClipView: 0x1095dd340>

View hierarchy (parents):
      - 0x1095dd340 (class <NSClipView>): <NSClipView: 0x1095dd340>, id=_NS:918, tag=-1
     - 0x1095aa700 (class <NSScrollView>): <NSScrollView: 0x1095aa700>, id=_NS:897, tag=-1
    - 0x109510850 (class <NSView>): <NSCustomView: 0x109510850>, id=_NS:889, tag=-1
   - 0x1095cffb0 (class <SPSplitView>): <SPSplitView: 0x1095cffb0>, id=_NS:843, tag=-1
  - 0x109554c60 (class <NSView>): <NSView: 0x109554c60>, id=_NS:841, tag=-1
 - 0x1095d7a90 (class <SPSplitView>): <SPSplitView: 0x1095d7a90>, id=_NS:838, tag=-1
- 0x107a3d900 (class <NSView>): <NSView: 0x107a3d900>, id=QueryTabView, tag=-1

View hierarchy (own children): 
- 0x109500dd0 (class <SPCopyTable>): <SPCopyTable: 0x109500dd0>, id=_NS:920, tag=0

In Window: (null)

self: 0x1095d5340 (class <_NSViewAuxiliary>)

registration info for pair (snd=0x1095dd340,obs=0x1095d5340):
 observer: 0x1095d5340 (class SPCopyTable) description: <SPCopyTable: 0x1095d5340>
  view info: id=_NS:711, tag=0

OK this table view is inside the Query tab so it can only be the Query results table.
That object was initially added as an observer here:

backtrace:
(
    0   Sequel Pro                          0x0000000100134678 -[NSNotificationCenter(SPScrollViewDebug) sp_addObserver:selector:name:object:] + 309
    1   AppKit                              0x00007fff8bb4f9a8 -[NSTableView setLayer:] + 97
    2   AppKit                              0x00007fff8ba471d7 -[NSView(NSInternal) _createLayerAndInitialize] + 208
    3   AppKit                              0x00007fff8ba480da -[NSView(NSInternal) _updateLayerGeometryFromView] + 39
    4   AppKit                              0x00007fff8ba576d5 -[NSView _gainedLayerTreeHostAncestor] + 352
    5   AppKit                              0x00007fff8ba5755f -[NSView _recursiveGainedLayerTreeHostAncestor] + 27
    6   AppKit                              0x00007fff8ba4afe5 -[NSView _childrenGainedLayerTreeAncestor] + 340
    7   AppKit                              0x00007fff8ba89d93 -[NSClipView _recursiveGainedLayerTreeHostAncestor] + 43
    8   AppKit                              0x00007fff8ba4afe5 -[NSView _childrenGainedLayerTreeAncestor] + 340
    9   AppKit                              0x00007fff8ba46778 -[NSView _doSetWantsLayerYES] + 509
    10  AppKit                              0x00007fff8ba46363 -[NSView setWantsLayer:] + 487
    11  AppKit                              0x00007fff8bc04836 -[NSView _setHasAutoSetWantsLayer:] + 156
    12  AppKit                              0x00007fff8ba1fa3a -[NSScrollView _setHasAutoSetWantsLayer:] + 301
    13  AppKit                              0x00007fff8ba24bad -[NSScrollView _updateAutomaticInclusiveLayerSupport] + 125
    14  CoreFoundation                      0x00007fff9573b24c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    15  CoreFoundation                      0x00007fff9571ab65 __CFRunLoopDoBlocks + 341
    16  CoreFoundation                      0x00007fff9571a354 __CFRunLoopRun + 948
    17  CoreFoundation                      0x00007fff95719d38 CFRunLoopRunSpecific + 296
    18  HIToolbox                           0x00007fff81db4d55 RunCurrentEventLoopInMode + 235
    19  HIToolbox                           0x00007fff81db4b8f ReceiveNextEventCommon + 432
    20  HIToolbox                           0x00007fff81db49cf _BlockUntilNextEventMatchingListInModeWithFilter + 71
    21  AppKit                              0x00007fff8ba3d236 _DPSNextEvent + 1067
    22  AppKit                              0x00007fff8ba3c665 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
    23  AppKit                              0x00007fff8ba311c8 -[NSApplication run] + 682
    24  AppKit                              0x00007fff8b9fa45e NSApplicationMain + 1176
    25  Sequel Pro                          0x00000001000024b4 start + 52
)

And deallocated here:

self =0x1095d5340 was originally dealloc'ed at:

dealloc backtrace:
(
    0   Sequel Pro                          0x0000000100134845 -[SPTableView(SPScrollViewDebug) sp_dealloc] + 82
    1   Sequel Pro                          0x000000010010aaa7 -[SPCopyTable dealloc] + 80
    2   libobjc.A.dylib                     0x00007fff89ad5b18 _ZN11objc_object17sidetable_releaseEb + 242
    3   libobjc.A.dylib                     0x00007fff89ad0ebb _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 477
    4   CoreFoundation                      0x00007fff956d9a72 _CFAutoreleasePoolPop + 50
    5   CoreFoundation                      0x00007fff95723e05 CFRunLoopTimerInvalidate + 629
    6   CoreFoundation                      0x00007fff957236ba __CFRunLoopDoTimer + 1130
    7   CoreFoundation                      0x00007fff957231da __CFRunLoopDoTimers + 298
    8   CoreFoundation                      0x00007fff9571a6d1 __CFRunLoopRun + 1841
    9   CoreFoundation                      0x00007fff95719d38 CFRunLoopRunSpecific + 296
    10  HIToolbox                           0x00007fff81db4d55 RunCurrentEventLoopInMode + 235
    11  HIToolbox                           0x00007fff81db4b8f ReceiveNextEventCommon + 432
    12  HIToolbox                           0x00007fff81db49cf _BlockUntilNextEventMatchingListInModeWithFilter + 71
    13  AppKit                              0x00007fff8ba3d236 _DPSNextEvent + 1067
    14  AppKit                              0x00007fff8ba3c665 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
    15  AppKit                              0x00007fff8ba311c8 -[NSApplication run] + 682
    16  AppKit                              0x00007fff8b9fa45e NSApplicationMain + 1176
    17  Sequel Pro                          0x00000001000024b4 start + 52
)

Causing a crash here:

(
    0   CoreFoundation                      0x00007fff957a5bd2 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff89adb4fa objc_exception_throw + 48
    2   Sequel Pro                          0x0000000100134428 +[NSNotificationCenter(SPScrollViewDebug) load] + 0
    3   CoreFoundation                      0x00007fff95731a0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    4   CoreFoundation                      0x00007fff9573199f ___CFXRegistrationPost_block_invoke + 63
    5   CoreFoundation                      0x00007fff95731917 _CFXRegistrationPost + 407
    6   CoreFoundation                      0x00007fff95731682 ___CFXNotificationPost_block_invoke + 50
    7   CoreFoundation                      0x00007fff956ee442 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1922
    8   CoreFoundation                      0x00007fff956ed695 _CFXNotificationPost + 693
    9   Foundation                          0x00007fff8917f31a -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
    10  AppKit                              0x00007fff8bb2959d -[NSView _postBoundsChangeNotification] + 175
    11  AppKit                              0x00007fff8bb29482 -[NSView translateOriginToPoint:] + 287
    12  AppKit                              0x00007fff8bb276a9 -[NSClipView _immediateScrollToPoint:] + 1277
    13  AppKit                              0x00007fff8bb27104 -[NSClipView scrollToPoint:] + 241
    14  AppKit                              0x00007fff8bb64b44 -[NSScrollView scrollClipView:toPoint:] + 75
    15  AppKit                              0x00007fff8bb0c223 -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:] + 1692
    16  AppKit                              0x00007fff8bb0b9b1 -[NSClipView _reflectDocumentViewFrameChange] + 128
    17  AppKit                              0x00007fff8ba2349f -[NSClipView setContentInsets:] + 380
    18  AppKit                              0x00007fff8ba2288d -[NSScrollView _applyContentAreaLayout:] + 1001
    19  AppKit                              0x00007fff8ba21539 -[NSScrollView tile] + 2761
    20  AppKit                              0x00007fff8ba209e7 -[NSScrollView _tileWithoutRecursing] + 51
    21  AppKit                              0x00007fff8ba2b441 -[NSScrollView reflectScrolledClipView:] + 1030
    22  AppKit                              0x00007fff8ba2a16f -[NSClipView _selfBoundsChanged] + 815
    23  AppKit                              0x00007fff8ba29c47 -[NSClipView setBoundsOrigin:] + 59
    24  AppKit                              0x00007fff8ba295fb -[NSClipView setDocumentView:] + 700
    25  AppKit                              0x00007fff8ba290d7 -[NSScrollView setDocumentView:] + 113
    26  AppKit                              0x00007fff8ba08c27 -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 368
    27  AppKit                              0x00007fff8bb19707 -[NSNib _instantiateNibWithExternalNameTable:options:] + 677
    28  AppKit                              0x00007fff8bddaf88 -[NSNib instantiateNibWithOwner:topLevelObjects:] + 212
    29  Sequel Pro                          0x000000010002f33a -[SPDatabaseDocument init] + 1178
    30  Sequel Pro                          0x00000001000f5035 -[SPWindowController addNewConnection:] + 60
    31  Sequel Pro                          0x0000000100146bee -[SPAppController(SPWindowManagement) newTab:] + 441
    32  libsystem_trace.dylib               0x00007fff93aa4082 _os_activity_initiate + 75
    33  AppKit                              0x00007fff8bca6cf1 -[NSApplication sendAction:to:from:] + 460
    34  AppKit                              0x00007fff8bca6a8b -[NSMenuItem _corePerformAction] + 336
    35  AppKit                              0x00007fff8bca67eb -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 114
    36  libsystem_trace.dylib               0x00007fff93aa4082 _os_activity_initiate + 75
    37  AppKit                              0x00007fff8bca56d9 -[NSMenu performKeyEquivalent:] + 357
    38  AppKit                              0x00007fff8bca4880 -[NSApplication _handleKeyEquivalent:] + 920
    39  AppKit                              0x00007fff8bbca6c9 -[NSApplication sendEvent:] + 4274
    40  AppKit                              0x00007fff8ba3123a -[NSApplication run] + 796
    41  AppKit                              0x00007fff8b9fa45e NSApplicationMain + 1176
    42  Sequel Pro                          0x00000001000024b4 start + 52
)

I had hoped we would see a call to -release but it's just an ordinary autorelease. Our chances of actually finding that issue seem to dwindle.

@dmoagx
Collaborator
dmoagx commented Oct 1, 2015

Different idea:
The notification sender is always an NSClipView. In our xib files those clip views are always hidden objects. But when I create a new XIB and add a table view, the clip view will be a visible tree node.
Perhaps this does confuse the loader in recent versions of OS X.

@dmoagx
Collaborator
dmoagx commented Oct 1, 2015

Btw, all stack traces show -[NSTableView setLayer:] as the subscribing method. That is not correct (compiler optimization?). It actually happens in -[NSTableView _startObservingViewDidScroll] (which is called by setLayer:) and -[NSTableView _stopObservingViewDidScroll] .

@dmoagx
Collaborator
dmoagx commented Oct 13, 2015

There has only been one report so far, but it looks like the timing of events is quite a bit different than I thought:

registration info for pair (snd=0x11097fef0,obs=0x10df0eef0):
 at 2015-10-13 11:47:30 +0000 (mach time: 169585.939404)
observer: 0x10df0eef0 (class SPTableView) description: <SPTableView: 0x10df0eef0>
  view info: id=TableStructureIndexesTableView, tag=0

(...)
self =0x10df0eef0 was originally dealloc'ed at:
  at 2015-10-13 11:48:01 +0000 (mach time: 169617.392328)

(...)

-[NSObject(SPObjectAdditions) _scrollViewDidChangeBounds:] tripped!
  at 2015-10-13 13:02:08 +0000 (mach time: 174064.980622)

(...)
    28  AppKit                              0x00007fff9ef75c5c -[NSNib instantiateNibWithOwner:topLevelObjects:] + 212
    29  Sequel Pro                          0x000000010002f15a -[SPDatabaseDocument init] + 1178
    30  Sequel Pro                          0x00000001000f7b36 -[SPWindowController addNewConnection:] + 60
    31  Sequel Pro                          0x000000010014a09d -[SPAppController(SPWindowManagement) newTab:] + 441
(...)

So while I thought this would mostly be an object being created and immediately dealloc'd again, it looks like opening a new tab is causing another tab (maybe even closed already?) to crash.

New report:

registration info for pair (snd=0x10886ca50,obs=0x1088e3b20):
 at 2015-10-14 8:45:15 AM +0000 (mach time: 7252.243449)
observer: 0x1088e3b20 (class SPTableView) description: &lt;SPTableView: 0x1088e3b20&gt;
  view info: id=TableStructureIndexesTableView, tag=0


self =0x1088e3b20 was originally dealloc'ed at:

0x1088e3b20 dealloc
  at 2015-10-14 8:48:20 AM +0000 (mach time: 7437.620821)


-[NSObject(SPObjectAdditions) _scrollViewDidChangeBounds:] tripped!
  at 2015-10-14 9:01:14 AM +0000 (mach time: 8211.270031)
@MattyAyOh

Hey Max,
I have been working on an application that is entirely different than Sequel Pro-- but we have been seeing this same exception being thrown.

This thread of yours is the only resource I've been able to find, and I appreciate all the work you've done thusfar. It's very cool that you log every step of your debugging process.

I will probably be researching this for a while-- it's a fairly prevalent issue in our software, so I will be sure to keep you up to date with anything that I find

@dmoagx
Collaborator
dmoagx commented Oct 16, 2015

Hi Matt,
as sad as it sounds, it's nice to hear we are not the only ones plagued by that crash. 😑

I just checked and we are at 30-80 crash reports per day on this right now and I don't feel closer to catching this at all...

@MattyAyOh

Wow that's a lot more. We are seeing maybe a couple a day, but we also can't 100% reproduce it.

Have you been able to find reproduction steps within SequelPro?

@dmoagx
Collaborator
dmoagx commented Oct 16, 2015

Many reports suggest it happens when opening a new window or tab (cmd+N / cmd+T), though it is not limited to that.
Also I feel like 10.10 and 10.11 are much more likely to crash than 10.9.

I'm still on 10.9 and I've not been able to reproduce this in any way (I think it happened once to me at random).

(It even heisenbugged me once but that has probably been just a fluke.)

@MattyAyOh

Okay yeah we are in the same boat. We actually just dropped 10.9 support last week, but we did notice to only see it in 10.10 and 10.11. We also do not have reproduction steps, and I personally have only seen it rarely. We are an NSDocument based application, and we notice it sometimes when switching documents

@MattyAyOh

Oh yes also, one of our devs noted that he was only able to see it with no external monitors (Macbook pro), and no mouse connected. But that hasn't been confirmed to be a cause

@dmoagx
Collaborator
dmoagx commented Oct 16, 2015

That is interesting, as I work with an external monitor most of the time.

Going by reports the MacBookPro11,x and MacBookPro12,x models have reported about as many crashes as all other models combined. However that is not so surprising as that are Apples most popular products (and our userbase is mostly semi-/pro users).
Comparing this particular crash to all other crashes the share of MacBookPro11,x and MacBookPro12,x models is basically the same: about 50%.

@dmoagx
Collaborator
dmoagx commented Oct 16, 2015

Numbers regarding displays:

  • of 159 crash reports with hardware info
  • 16 had Thunderbolt Displays attached (the only external monitor I can see via crash reports)
  • and of those 7 had a _scrollViewDidChangeBounds crash

Given that 50% of our crashes are coming from the _scrollView thing I'd say it's unlikely an external monitor is making a difference.
Graphics cards are all over the place, too.

@MattyAyOh

Lmao literally right after I read your message, I saw the crash. (By creating a new document with CMD+N, as you suggested ^^)
I luckily had my external monitors and mouse plugged in (I've had them unplugged pretty much all day trying to find reproduction steps), so that is debunked.

My stacktrace:

<_NSCallStackArray 0x608000a50740>(
0   ???                                 0x000000010183ea15 0x0 + 4320389653,
1   Snagit                              0x000000010000d610 main + 0,
2   CoreFoundation                      0x00007fff8c009634 _CFXNotificationPost + 3140,
3   Foundation                          0x00007fff8bc5faa1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66,
4   AppKit                              0x00007fff97b8f5aa -[NSView _postBoundsChangeNotification] + 186,
5   AppKit                              0x00007fff97ba178a -[NSView translateOriginToPoint:] + 287,
6   AppKit                              0x00007fff97b9fc24 -[NSClipView _immediateScrollToPoint:] + 2015,
7   AppKit                              0x00007fff97f69112 -[NSScrollAnimationHelper _doFinalAnimationStep] + 146,
8   AppKit                              0x00007fff97efd6cb -[NSAnimationHelper _doAnimationStep] + 73,
9   AppKit                              0x00007fff97f68f2c -[NSScrollAnimationHelper _doAnimationStep] + 75,
10  AppKit                              0x00007fff97efd801 _NSAnimationHelperTimerCallback + 43,
11  CoreFoundation                      0x00007fff8c0b02e4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20,
12  CoreFoundation                      0x00007fff8c0aff73 __CFRunLoopDoTimer + 1059,
13  CoreFoundation                      0x00007fff8c12353d __CFRunLoopDoTimers + 301,
14  CoreFoundation                      0x00007fff8c06b608 __CFRunLoopRun + 2024,
15  CoreFoundation                      0x00007fff8c06abd8 CFRunLoopRunSpecific + 296,
16  HIToolbox                           0x00007fff946b956f RunCurrentEventLoopInMode + 235,
17  HIToolbox                           0x00007fff946b91ee ReceiveNextEventCommon + 179,
18  HIToolbox                           0x00007fff946b912b _BlockUntilNextEventMatchingListInModeWithFilter + 71,
19  AppKit                              0x00007fff97b0c8ab _DPSNextEvent + 978,
20  AppKit                              0x00007fff97b0be58 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346,
21  AppKit                              0x00007fff97b01af3 -[NSApplication run] + 594,
22  AppKit                              0x00007fff97a7e244 NSApplicationMain + 1832,
23  Snagit                              0x000000010000d632 main + 34,
24  libdyld.dylib                       0x00007fff933485c9 start + 1
)

It looks a little different than our standard logged stacktraces,
[NSScrollAnimationHelper _doFinalAnimationStep] calls [NSClipView _immediateScrollToPoint:];
instead of [NSClipView scrollToPoint:]

@MattyAyOh

Can you check the stacktraces for the 7 who had thunderbolt displays , and see who called [NSClipView _immediateScrollToPoint:]?

@dmoagx
Collaborator
dmoagx commented Oct 16, 2015

Yeah, _immediateScrollToPoint: is also popular.

Can you check the stacktraces for the 7 who had thunderbolt displays , and see who called [NSClipView _immediateScrollToPoint:]?

6 of 7. (The one not matching is http://log.sequelpro.com/viewreports/4876/114837)
Of 779 _scrollView crashes 751 had _immediateScrollToPoint:
Also 750 had both _immediateScrollToPoint: and scrollToPoint: (as its direct or indirect caller).

But only 282 had a real scrolling as source (i.e. -[NSView scrollWheel:]). (by which I don't mean that the view being scrolled is the one that is actually involved in the crash!)

@MattyAyOh

All that data, and it just makes it more confusing :(

Just to double check, when you said 6 out of 7, did you mean 6 out of 7 had a stack trace like:

...
[NSClipView _immediateScrollToPoint:]
[NSScrollAnimationHelper _doFinalAnimationStep]
...

and could you check the x/143 users who didn't have a external monitor plugged in and see how many have a stack trace like

...
[NSClipView _immediateScrollToPoint:]
[NSClipView scrollToPoint:]
...

It may mean nothing, but I'm just trying to see if; while the exception can be thrown with/without an external monitor, the stack trace is different.

I'm about to use the disassembler and step through the instructions to try to figure this out, so I want to make sure I have an idea of where to look before I spend a lot of time going down the wrong path haha.

Also, after talking to another dev, he claims that if you do not have your mouse plugged in, you won't see the issue. I had my mouse plugged in when I crashed last time, so I don't think this is true-- but I was wondering if you had any mouse data?

Lastly, It appears your time here is volunteered? So I just want to truly thank you for your time :) Please don't let me spend too much of it

@dmoagx
Collaborator
dmoagx commented Oct 16, 2015

did you mean 6 out of 7 had a stack trace like:

No, 6/7 had _immediateScrollToPoint:.

 -[NSClipView _immediateScrollToPoint:]
 -[NSScrollAnimationHelper _doFinalAnimationStep] 

is rather rare for me: only 3 of 779 cases.

users who didn't have a external monitor plugged

I can only see Thunderbolt Displays. I can't make any assertion about other kinds of external monitors. Not even if one is present or not.
But as I've said above,

...
[NSClipView _immediateScrollToPoint:]
(... possibly ...)
[NSClipView scrollToPoint:]
...

happened in 750 of 779 cases.

Personally I think that seems too unbalanced (95%) to come from external display attached or not (in that case I'd estimate the ratio to be more like 20-50%). But then, we also have a different codebase.

if you do not have your mouse plugged in, you won't see the issue.

I don't think that affects whether it happens or not, but I've seen the stack trace differ (e.g. because of the rubberband scrolling for trackpads).

Lastly, It appears your time here is volunteered?

Yes, but if it somehow helps with this annoying issue then that's fine ;)

@dmoagx
Collaborator
dmoagx commented Oct 16, 2015

I just realized something incredibly stupid...

In SPTableView we override viewWillMoveToWindow: without calling super.
However T H A T is the exact method, which is called to stop observing NSViewBoundsDidChangeNotification (the _scrollViewDidChangeBounds notification).

Normally it would be called during the dealloc phase with window == nil to remove that observer, which simply never happens for our table views.

Arrrrggggghhhhh

@MattyAyOh

Ah, that's awesome!

Let me know if that works for you :)

Unfortunately we don't seem to have that issue. How did you know that -[NSWindow viewWillMoveToWindow] has the stop observation call?

@dmoagx
Collaborator
dmoagx commented Oct 17, 2015

I added a breakpoint in
-[NSNotificationCenter removeObserver:name:object:] with condition ($rcx==0 || (BOOL)[ @"NSViewBoundsDidChangeNotification" isEqualToString:(id)$rcx]) && (BOOL)[(id)$rdx isKindOfClass:[NSTableView class]]

(the NSTableView check is a constraint I added because our zombie tracking code identified the overreleased object as a child class of NSTableView)

Then I remembered that I had just seen viewWillMoveToWindow: in our code somewhere...

@MattyAyOh

holy cow that is amazing. I must try that when I go into work on Monday.

You potentially just saved me a crap ton of headache.

If I may bother you with some more questions-- what does the rcx and rdx register store?

i'm assuming rdx == destination? so the receiver of the notification?
and based off of your snippet, rcx appears to be the second argument?

From briefly googling, I can't seem to find a reference for what registers are used for what in Mac applications

@dmoagx
Collaborator
dmoagx commented Oct 17, 2015

Yeah, I have to look up the registers all the time myself. :)
For 64 Bit OS X uses the systemv/amd convention:

integer arguments: RDI, RSI, RDX, RCX, R8, R9, XMM0–7
return value: RAX

But since objective-c methods become basically C functions after compiling $rdi will be self and $rsi will be _cmd (the method name). So the real function arguments start at $rdx.

For removeObserver:name:object: this means rdx is the observer, rcx the notification name and r8 the notification sender.

@rowanbeentje
Collaborator

Wow. Great work, @dmoagx! 👍 👍

@Bibiko
Collaborator
Bibiko commented Oct 17, 2015

Congrats after such a Sisyphus work :)

@MattyAyOh

Thanks for the info, it really helps. I believe with your strategy I will be able to solve the issue for us :)

Another quick question if you have the time--

Whenever I type register read in lldb, I never get the registers you mentioned; rather, I get:

General Purpose Registers:
       rbx = 0x00006180002ba3a0
       rbp = 0x00007fff5fbfdec0
       rsp = 0x00007fff5fbfde50
       r12 = 0x00006180001c12c0
       r13 = 0x0000000100563e40  @"selectedObjects"
       r14 = 0x0000000000000000
       r15 = 0x00007fff5fbfded0
       rip = 0x00007fff8bc9a082  Foundation`NSKeyValueNotifyObserver + 61

Or something like that. Am I using the wrong command to view the registers? Or am I not in the correct state somehow?

@MattyAyOh

Oh okay nvm I see, literally after I asked you--
I can only view all of the registers when on the top stack frame. I'm assuming because the backtrace can't figure out what was in the registers at any other time-- but it can figure it out for rbx, rbp, rsp, etc

@MattyAyOh

For anybody who stumbles across this, I found that:

frame #39: 0x00007fff96372f91 AppKit`-[NSView removeFromSuperview] + 453

was the line that removed my object from observing the NSView. We needed to make sure this was happening in the correct order

@dmoagx dmoagx added this to the 1.1.1 milestone Oct 30, 2015
@dmoagx
Collaborator
dmoagx commented Feb 20, 2016
@dmoagx dmoagx closed this Feb 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment