[Qt-interest] [OS X] Lion Sandboxing? Terminating app due to uncaught exception 'NSRangeException'
Till Oliver Knoll
till.oliver.knoll at gmail.com
Tue Aug 30 00:33:36 CEST 2011
Hello,
I am trying to put my application into a "sandbox" on "Lion" (OS X 10.7)
by following the procedures here:
https://developer.apple.com/library/mac/#documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40005929-CH1-SW1
The only entitlement I have given to my application is
"com.apple.security.documents.user-selected.read-write" which according
to above document should use the "Powerbox" daemon for rendering file
dialog boxes from a separate process:
"Any time an application running inside a sandbox invokes an NSOpenPanel
or NSSavePanel dialog, rather than showing the panels directly, AppKit
automatically asks the Powerbox to present the dialog. From a developer
perspective, there are no code changes required in terms of how these
panels are used; this process is fully transparent."
So I was hoping this would also work "out of the box" with a given Qt
application on Qt 4.7.3 Cocoa, I also tried with the latest Qt 4.8.0
Beta, same result.
However when I try to access a native QFileDialog the application
crashes (see below for crash report)!
Anyone else tried succesfully to put a Qt Cocoa application into a
sandbox on "Lion"? (Note that this will become a requirement from late
2011 onwards for the Mac App Store).
Upon application start I see that the proper "sandboxed" Container is
indeed created under ~/Library/Containers/net.company.MyApp - my config
files (QSettings ...) are stored there properly.
Basically I have:
- Created a self-signed Certificate for code signing
- Made sure I have CFBundleIdentifier and CFBundleName
defined in the Info.plist
- Added the following linker flag:
QMAKE_LFLAGS += -sectcreate __TEXT __info_plist /path/to/Info.plist
- Signed the executable with:
codesign -f -s "My codesign certificate" --entitlements
/path/to/entitlements.plist /path/to/application.app
- A check with:
codesign -d --entitlements - /path/to/MyApp.app/
reveals the expected:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.documents.user-selected.read-write</key>
<true/>
</dict>
</plist>
Here is the crash report when I execute the window-modal QFileDialog as
window sheet:
QFileDialog *fileDialog = new QFileDialog(this, Qt::Sheet);
...
fileDialog->setWindowModality(Qt::WindowModal);
fileDialog->setAcceptMode(QFileDialog::AcceptSave);
fileDialog->setAttribute(Qt::WA_DeleteOnClose);
...
fileDialog->open(this, SLOT(handleFileSaveAsSelected(const QString &)));
Crash log:
Process: Screenie [3667]
Path: /path/to/MyApp
Identifier: net.company.MyApp
Version: ??? (1.0)
Code Type: X86-64 (Native)
Parent Process: launchd [206]
Date/Time: 2011-08-30 00:27:09.791 +0200
OS Version: Mac OS X 10.7.1 (11B26)
Report Version: 9
Interval Since Last Report: 25212 sec
Crashes Since Last Report: 14
Per-App Interval Since Last Report: 105 sec
Per-App Crashes Since Last Report: 4
Anonymous UUID: 0099742B-E1E5-4903-B8C6-0C8C1E37846B
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
objc[3667]: garbage collection is OFF
*** Terminating app due to uncaught exception 'NSRangeException',
reason: 'Cannot remove an observer <NSRemoteSavePanel 0x105e48990> for
the key path "panelSettings" from <NSRemoteSavePanel 0x105e48990>
because it is not registered as an observer.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff90f30986
__exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff91b70d5e
objc_exception_throw + 43
2 CoreFoundation 0x00007fff90f307ba
+[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff90f30744
+[NSException raise:format:] + 116
4 Foundation 0x00007fff9420298a
-[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:]
+ 619
5 Foundation 0x00007fff942026c8
-[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] + 121
6 RemoteViewServices 0x00007fff8e426fe6
-[NSRemoteSavePanel dealloc] + 39
7 libobjc.A.dylib 0x00007fff91b6903c
_ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 434
8 CoreFoundation 0x00007fff90ebe6a5
_CFAutoreleasePoolPop + 37
9 Foundation 0x00007fff941a0f01
-[NSAutoreleasePool release] + 154
10 QtGui 0x000000010011dd1d
_ZN18QFileDialogPrivate18showCocoaFilePanelEv + 157
11 QtGui 0x000000010011dd5c
_ZN18QFileDialogPrivate14setVisible_sysEb + 44
12 QtGui 0x00000001005dbe7d
_ZN11QFileDialog10setVisibleEb + 205
13 QtGui 0x00000001005d6538
_ZN7QDialog4openEv + 136
14 MyApp 0x0000000100007007
_ZN10MainWindow25on_saveAsAction_triggeredEv + 359
15 MyApp 0x000000010001352f
_ZN10MainWindow11qt_metacallEN11QMetaObject4CallEiPPv + 95
16 QtCore 0x0000000100ecd446
_ZN11QMetaObject8activateEP7QObjectPKS_iPPv + 2150
17 QtGui 0x000000010012d581
_ZN7QAction9triggeredEb + 49
18 QtGui 0x000000010012e914
_ZN7QAction8activateENS_11ActionEventE + 180
19 QtGui 0x00000001000e3d5a
-[QCocoaMenuLoader qtDispatcherToQAction:] + 106
20 CoreFoundation 0x00007fff90f2011d -[NSObject
performSelector:withObject:] + 61
21 AppKit 0x00007fff8cd37852
-[NSApplication sendAction:to:from:] + 139
22 AppKit 0x00007fff8ce2434f -[NSMenuItem
_corePerformAction] + 399
23 AppKit 0x00007fff8ce24086
-[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 125
24 AppKit 0x00007fff8d0bfe9c -[NSMenu
_internalPerformActionForItemAtIndex:] + 38
25 AppKit 0x00007fff8cf523f1
-[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 138
26 AppKit 0x00007fff8cd9e0bf
NSSLMMenuEventHandler + 339
27 HIToolbox 0x00007fff93e668ec
_ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec
+ 1263
28 HIToolbox 0x00007fff93e65ef8
_ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec
+ 446
29 HIToolbox 0x00007fff93e7cd03
SendEventToEventTarget + 76
30 HIToolbox 0x00007fff93ec3249
_ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef
+ 398
31 HIToolbox 0x00007fff93faa0f1
SendMenuCommandWithContextAndModifiers + 56
32 HIToolbox 0x00007fff93ff05e1
SendMenuItemSelectedEvent + 253
33 HIToolbox 0x00007fff93ebc32d
_ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 101
34 HIToolbox 0x00007fff93eb3a75
_ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 600
35 HIToolbox 0x00007fff93eb3034
_HandleMenuSelection2 + 585
36 AppKit 0x00007fff8cc9dce1
_NSHandleCarbonMenuEvent + 250
37 AppKit 0x00007fff8cc336c7
_DPSNextEvent + 1993
38 AppKit 0x00007fff8cc32a95
-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
39 AppKit 0x00007fff8cc2f3d6
-[NSApplication run] + 463
40 QtGui 0x00000001000ef750
_ZN19QEventDispatcherMac13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE
+ 1824
41 QtCore 0x0000000100eb4664
_ZN10QEventLoop13processEventsE6QFlagsINS_17ProcessEventsFlagEE + 68
42 QtCore 0x0000000100eb4a14
_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE + 324
43 QtCore 0x0000000100eb790c
_ZN16QCoreApplication4execEv + 188
44 MyApp 0x0000000100005dfb main + 59
45 MyApp 0x0000000100005644 start + 52
46 ??? 0x0000000000000002 0x0 + 2
)
Performing @selector(qtDispatcherToQAction:) from sender NSMenuItem
0x1014ce060
terminate called throwing an exception
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff91aadce2 __pthread_kill + 10
1 libsystem_c.dylib 0x00007fff8f5f57d2 pthread_kill + 95
2 libsystem_c.dylib 0x00007fff8f5e6a7a abort + 143
3 libc++abi.dylib 0x00007fff8a6667bc abort_message + 214
4 libc++abi.dylib 0x00007fff8a663fcf
default_terminate() + 28
5 libobjc.A.dylib 0x00007fff91b711b9 _objc_terminate + 94
6 libc++abi.dylib 0x00007fff8a664001
safe_handler_caller(void (*)()) + 11
7 libc++abi.dylib 0x00007fff8a663ff6
__cxxabiv1::__terminate(void (*)()) + 9
8 libc++abi.dylib 0x00007fff8a664346
__cxa_call_terminate + 59
9 libc++abi.dylib 0x00007fff8a6647c3
__gxx_personality_v0 + 207
10 libunwind.dylib 0x00007fff8c6594c6 unwind_phase2 + 160
11 libunwind.dylib 0x00007fff8c65896e
_Unwind_RaiseException + 218
12 com.apple.Foundation 0x00007fff94202713
-[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] + 196
13 com.apple.RemoteViewServices 0x00007fff8e426fe6
-[NSRemoteSavePanel dealloc] + 39
14 libobjc.A.dylib 0x00007fff91b6903c (anonymous
namespace)::AutoreleasePoolPage::pop(void*) + 434
15 com.apple.CoreFoundation 0x00007fff90ebe6a5
_CFAutoreleasePoolPop + 37
16 com.apple.Foundation 0x00007fff941a0f01
-[NSAutoreleasePool release] + 154
17 QtGui 0x000000010011dd1d
QFileDialogPrivate::showCocoaFilePanel() + 157
18 QtGui 0x000000010011dd5c
QFileDialogPrivate::setVisible_sys(bool) + 44
19 QtGui 0x00000001005dbe7d
QFileDialog::setVisible(bool) + 205
20 QtGui 0x00000001005d6538 QDialog::open() + 136
21 net.company.MyApp 0x0000000100007007
MainWindow::on_saveAsAction_triggered() + 359
22 net.company.MyApp 0x000000010001352f
MainWindow::qt_metacall(QMetaObject::Call, int, void**) + 95
23 QtCore 0x0000000100ecd446
QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 2150
24 QtGui 0x000000010012d581
QAction::triggered(bool) + 49
25 QtGui 0x000000010012e914
QAction::activate(QAction::ActionEvent) + 180
26 QtGui 0x00000001000e3d5a -[QCocoaMenuLoader
qtDispatcherToQAction:] + 106
27 com.apple.CoreFoundation 0x00007fff90f2011d -[NSObject
performSelector:withObject:] + 61
28 com.apple.AppKit 0x00007fff8cd37852 -[NSApplication
sendAction:to:from:] + 139
29 com.apple.AppKit 0x00007fff8ce2434f -[NSMenuItem
_corePerformAction] + 399
30 com.apple.AppKit 0x00007fff8ce24086 -[NSCarbonMenuImpl
performActionWithHighlightingForItemAtIndex:] + 125
31 com.apple.AppKit 0x00007fff8d0bfe9c -[NSMenu
_internalPerformActionForItemAtIndex:] + 38
32 com.apple.AppKit 0x00007fff8cf523f1 -[NSCarbonMenuImpl
_carbonCommandProcessEvent:handlerCallRef:] + 138
33 com.apple.AppKit 0x00007fff8cd9e0bf
NSSLMMenuEventHandler + 339
34 com.apple.HIToolbox 0x00007fff93e668ec
_ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec
+ 1263
35 com.apple.HIToolbox 0x00007fff93e65ef8
_ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec
+ 446
36 com.apple.HIToolbox 0x00007fff93e7cd03
SendEventToEventTarget + 76
37 com.apple.HIToolbox 0x00007fff93ec3249
_ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef
+ 398
38 com.apple.HIToolbox 0x00007fff93faa0f1
SendMenuCommandWithContextAndModifiers + 56
39 com.apple.HIToolbox 0x00007fff93ff05e1
SendMenuItemSelectedEvent + 253
40 com.apple.HIToolbox 0x00007fff93ebc32d
_ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 101
41 com.apple.HIToolbox 0x00007fff93eb3a75
_ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 600
42 com.apple.HIToolbox 0x00007fff93eb3034
_HandleMenuSelection2 + 585
43 com.apple.AppKit 0x00007fff8cc9dce1
_NSHandleCarbonMenuEvent + 250
44 com.apple.AppKit 0x00007fff8cc336c7 _DPSNextEvent + 1993
45 com.apple.AppKit 0x00007fff8cc32a95 -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
46 com.apple.AppKit 0x00007fff8cc2f3d6 -[NSApplication
run] + 463
47 QtGui 0x00000001000ef750
QEventDispatcherMac::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) +
1824
48 QtCore 0x0000000100eb4664
QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 68
49 QtCore 0x0000000100eb4a14
QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 324
50 QtCore 0x0000000100eb790c
QCoreApplication::exec() + 188
51 net.company.MyApp 0x0000000100005dfb main + 59
52 net.company.MyApp 0x0000000100005644 start + 52
More information about the Qt-interest-old
mailing list