New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPBeginAlertSheet crash #3213

Open
stuconnolly opened this Issue Oct 8, 2018 · 1 comment

Comments

2 participants
@stuconnolly
Member

stuconnolly commented Oct 8, 2018

Calling SPBeginAlertSheet from a thread other than the main one is causing the following exception:

2018-10-08 13:35:04.996076+0100 Sequel Pro[33485:812313] [General] An uncaught exception was raised
2018-10-08 13:35:04.996184+0100 Sequel Pro[33485:812313] [General] NSWindow drag regions should only be invalidated on the Main Thread!
2018-10-08 13:35:04.996353+0100 Sequel Pro[33485:812313] [General] (
0   CoreFoundation                      0x00007fff4e6a443d __exceptionPreprocess + 256
1   libobjc.A.dylib                     0x00007fff7a5b5720 objc_exception_throw + 48
2   CoreFoundation                      0x00007fff4e6bdec1 -[NSException raise] + 9
3   AppKit                              0x00007fff4bbc22a5 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 324
4   AppKit                              0x00007fff4bbbf68c -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1488
5   AppKit                              0x00007fff4bc7fedf -[NSPanel _initContent:styleMask:backing:defer:contentView:] + 50
6   AppKit                              0x00007fff4bbbf0b6 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
7   AppKit                              0x00007fff4bc7fe94 -[NSPanel initWithContentRect:styleMask:backing:defer:] + 64
8   AppKit                              0x00007fff4bbbd5c7 -[NSWindowTemplate nibInstantiate] + 495
9   AppKit                              0x00007fff4bb38646 -[NSIBObjectData instantiateObject:] + 267
10  AppKit                              0x00007fff4bb379b4 -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 579
11  AppKit                              0x00007fff4bb35be1 loadNib + 401
12  AppKit                              0x00007fff4bb350a9 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 696
13  AppKit                              0x00007fff4bb34cee -[NSBundle(NSNibLoading) loadNibNamed:owner:topLevelObjects:] + 204
14  AppKit                              0x00007fff4beeecc9 -[NSAlert init] + 101
15  Sequel Pro                          0x00000001001b2560 SPBeginAlertSheet + 96
16  Sequel Pro                          0x00000001000b3ec7 -[SPTablesList _addTable] + 3159
17  Sequel Pro                          0x00000001002435cd -[SPNamedThread run:] + 125
18  Foundation                          0x00007fff50940234 __NSThread__start__ + 1218
19  libsystem_pthread.dylib             0x0000000100d4ee6d _pthread_body + 126
20  libsystem_pthread.dylib             0x0000000100d51eff _pthread_start + 70
21  libsystem_pthread.dylib             0x0000000100d4de61 thread_start + 13
)
Assertion failed: (NSViewIsCurrentlyBuildingLayerTreeForDisplay() != currentlyBuildingLayerTree), function NSViewSetCurrentlyBuildingLayerTreeForDisplay, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1671/AppKit.subproj/NSView.m, line 14127.

The feedback reporter then causes the app to crash:

Thread 9 Crashed:: SPTablesList table addition task (SPDatabaseDocument#1)
0   libsystem_c.dylib             	0x00007fff7b72b289 __abort + 177
1   libsystem_c.dylib             	0x00007fff7b72b1d8 abort + 142
2   libsystem_c.dylib             	0x00007fff7b6f3868 __assert_rtn + 320
3   com.apple.AppKit              	0x00007fff4bc4a704 NSViewSetCurrentlyBuildingLayerTreeForDisplay + 255
4   com.apple.AppKit              	0x00007fff4bc4a537 NSViewBuildLayerTreeForDisplay + 53
5   com.apple.AppKit              	0x00007fff4bc4a49d -[NSWindow displayIfNeeded] + 232
6   com.apple.AppKit              	0x00007fff4bc4a30f __NSWindowGetDisplayCycleObserverForDisplay_block_invoke + 722
7   com.apple.AppKit              	0x00007fff4bc4541a NSDisplayCycleObserverInvoke + 170
8   com.apple.AppKit              	0x00007fff4bc44f8f NSDisplayCycleFlush + 1073
9   com.apple.QuartzCore          	0x00007fff5956b1d3 CA::Transaction::run_commit_handlers(CATransactionPhase) + 49
10  com.apple.QuartzCore          	0x00007fff5956ab9a CA::Transaction::commit() + 186
11  com.apple.QuartzCore          	0x00007fff59596505 CA::Transaction::release_thread(void*) + 209
12  libsystem_pthread.dylib       	0x00007fff7b8756fa _pthread_tsd_cleanup + 550
13  libsystem_pthread.dylib       	0x00007fff7b8786b1 _pthread_exit + 70
14  libsystem_pthread.dylib       	0x00007fff7b8754ab pthread_exit + 30
15  com.apple.Foundation          	0x00007fff509405fa +[NSThread exit] + 11
16  org.vafer.FeedbackReporter    	0x0000000106d17b94 -[FRExceptionReportingApplication reportException:] + 147
17  com.apple.AppKit              	0x00007fff4c00feb7 uncaughtErrorProc + 157
18  com.apple.CoreFoundation      	0x00007fff4e71b2e1 __handleUncaughtException + 775
19  libobjc.A.dylib               	0x00007fff7a5b7c81 _objc_terminate() + 91
20  libc++abi.dylib               	0x00007fff78db9dfe std::__terminate(void (*)()) + 8
21  libc++abi.dylib               	0x00007fff78db9be2 __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 27
22  libc++abi.dylib               	0x00007fff78dacbb9 __cxa_throw + 113
23  libobjc.A.dylib               	0x00007fff7a5b585a objc_exception_throw + 362
24  com.apple.CoreFoundation      	0x00007fff4e6bdec1 -[NSException raise] + 9
25  com.apple.AppKit              	0x00007fff4bbc22a5 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 324
26  com.apple.AppKit              	0x00007fff4bbbf68c -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1488
27  com.apple.AppKit              	0x00007fff4bc7fedf -[NSPanel _initContent:styleMask:backing:defer:contentView:] + 50
28  com.apple.AppKit              	0x00007fff4bbbf0b6 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
29  com.apple.AppKit              	0x00007fff4bc7fe94 -[NSPanel initWithContentRect:styleMask:backing:defer:] + 64
30  com.apple.AppKit              	0x00007fff4bbbd5c7 -[NSWindowTemplate nibInstantiate] + 495
31  com.apple.AppKit              	0x00007fff4bb38646 -[NSIBObjectData instantiateObject:] + 267
32  com.apple.AppKit              	0x00007fff4bb379b4 -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 579
33  com.apple.AppKit              	0x00007fff4bb35be1 loadNib + 401
34  com.apple.AppKit              	0x00007fff4bb350a9 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 696
35  com.apple.AppKit              	0x00007fff4bb34cee -[NSBundle(NSNibLoading) loadNibNamed:owner:topLevelObjects:] + 204
36  com.apple.AppKit              	0x00007fff4beeecc9 -[NSAlert init] + 101
37  com.sequelpro.SequelPro       	0x000000010658d560 SPBeginAlertSheet + 96 (SPAlertSheets.m:213)
38  com.sequelpro.SequelPro       	0x000000010648eec7 -[SPTablesList _addTable] + 3159 (SPTablesList.m:2471)
39  com.sequelpro.SequelPro       	0x000000010661e5cd -[SPNamedThread run:] + 125 (SPThreadAdditions.m:87)
40  com.apple.Foundation          	0x00007fff50940234 __NSThread__start__ + 1218
41  libsystem_pthread.dylib       	0x00007fff7b87533d _pthread_body + 126
42  libsystem_pthread.dylib       	0x00007fff7b8782a7 _pthread_start + 70
43  libsystem_pthread.dylib       	0x00007fff7b874425 thread_start + 13

Seems like a change in behaviour on 10.14 and we likely need to wrap NSAlert initialisation within a thread guard check.

@dmoagx

This comment has been minimized.

Show comment
Hide comment
@dmoagx

dmoagx Oct 8, 2018

Member

Sounds plausible, given that all UI interaction must happen on the main thread.
You can set Xcode to break every time a UI method is called from a background thread (which will result in a lot of breaking in SP 😢 )

Member

dmoagx commented Oct 8, 2018

Sounds plausible, given that all UI interaction must happen on the main thread.
You can set Xcode to break every time a UI method is called from a background thread (which will result in a lot of breaking in SP 😢 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment