Thread: [Pyobjc-dev] strange problem using NSWorkspace/NSTask to start PyObjC apps
Brought to you by:
ronaldoussoren
From: Robert K. <rob...@gm...> - 2011-11-21 06:21:23
|
Hey all, I'm running into a strange problem with PyObjC-based apps. The situation: I'm working on a .mailbundle (a plug-in for Apple Mail). From that plug-in, I want to start a PyObjC-based application. No matter what, this fails: the application gets a SIGSEGV (I'll post some more information below). I've used pretty much all methods of starting the application (NSWorkspace, NSTask, even executing "open -a APP" from the Python subprocess module), and it keeps failing. Of course, the app works without problems when started manually. Starting the app from a Python-shell using [NSWorkspace launchApplication:] works, too. Just not from within the plug-in. Even the simplest 'app' fails: -snip- from Foundation import * class MyTestClass(NSObject): pass -snip- Same thing: SIGSEGV. Starting other apps (like Safari) isn't a problem, so it doesn't seem to be some sandbox-type blocking. Below is the relevant part of the crashlog. All I've been able to find out is that objc_msgSend_vtable3 is an Objective-C runtime shortcut for getting 'self'. It smells like a memory issue, but I'd be grateful if anyone could help me out. -snip- Process: App1 [797] Path: /Users/USER/*/App1.app/Contents/MacOS/App1 Identifier: name.klep.app1 Version: 0.0.0 (0.0.0) Code Type: X86-64 (Native) Parent Process: launchd [301] Date/Time: 2011-11-21 06:49:06.394 +0100 OS Version: Mac OS X 10.7.2 (11C74) Report Version: 9 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x00007fc2dac50c60 VM Regions Near 0x7fc2dac50c60: MALLOC_TINY 0000000104e00000-0000000104f00000 [ 1024K] rw-/rwx SM=PRV --> STACK GUARD 00007fff5bc00000-00007fff5f400000 [ 56.0M] ---/rwx SM=NUL stack guard for thread 0 Application Specific Information: objc_msgSend() selector name: self objc[797]: garbage collection is OFF Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libobjc.A.dylib 0x00007fff8c84c0cd objc_msgSend_vtable3 + 13 1 _objc.so 0x0000000101ba5a71 pythonify_c_value + 573 2 _objc.so 0x0000000101b9d92e 0x101b80000 + 121134 3 org.python.python 0x0000000101a87b58 PyEval_EvalFrameEx + 13318 4 org.python.python 0x0000000101a8acd8 PyEval_EvalCodeEx + 1996 5 org.python.python 0x0000000101a8ae6c PyEval_EvalCode + 341 6 org.python.python 0x0000000101a87e0a PyEval_EvalFrameEx + 14008 7 org.python.python 0x0000000101a8acd8 PyEval_EvalCodeEx + 1996 8 org.python.python 0x0000000101a28abf PyClassMethod_New + 1378 9 org.python.python 0x0000000101a07d32 PyObject_Call + 97 10 org.python.python 0x0000000101a83c40 PyEval_CallObjectWithKeywords + 180 11 _objc.so 0x0000000101ba0bd3 0x101b80000 + 134099 12 org.python.python 0x0000000101a4cafa PyType_Modified + 891 13 org.python.python 0x0000000101a07d32 PyObject_Call + 97 14 org.python.python 0x0000000101a07eed PyObject_CallFunctionObjArgs + 178 15 org.python.python 0x0000000101a8576b PyEval_EvalFrameEx + 4121 16 org.python.python 0x0000000101a8acd8 PyEval_EvalCodeEx + 1996 17 org.python.python 0x0000000101a8ad4d PyEval_EvalCode + 54 18 org.python.python 0x0000000101aa208f Py_CompileString + 62 19 org.python.python 0x0000000101aa214f PyRun_FileExFlags + 157 20 org.python.python 0x0000000101a801f6 _PyBuiltin_Init + 4630 21 org.python.python 0x0000000101a87d77 PyEval_EvalFrameEx + 13861 22 org.python.python 0x0000000101a8acd8 PyEval_EvalCodeEx + 1996 23 org.python.python 0x0000000101a8ae6c PyEval_EvalCode + 341 24 org.python.python 0x0000000101a87e0a PyEval_EvalFrameEx + 14008 25 org.python.python 0x0000000101a8acd8 PyEval_EvalCodeEx + 1996 26 org.python.python 0x0000000101a8ad4d PyEval_EvalCode + 54 27 org.python.python 0x0000000101aa208f Py_CompileString + 62 28 org.python.python 0x0000000101aa214f PyRun_FileExFlags + 157 29 org.python.python 0x0000000101aa32a2 PyRun_SimpleFileExFlags + 392 30 name.klep.app1 0x0000000100004476 start + 12854 31 name.klep.app1 0x0000000100004a96 main + 1465 32 name.klep.app1 0x0000000100001274 start + 52 -snip- -- robert |
From: Ronald O. <ron...@ma...> - 2011-11-22 15:44:26
Attachments:
smime.p7s
|
On 21 Nov, 2011, at 7:08, Robert Klep wrote: > Hey all, > > I'm running into a strange problem with PyObjC-based apps. > > The situation: I'm working on a .mailbundle (a plug-in for Apple Mail). From that plug-in, I want to start a PyObjC-based application. No matter what, this fails: the application gets a SIGSEGV (I'll post some more information below). > > I've used pretty much all methods of starting the application (NSWorkspace, NSTask, even executing "open -a APP" from the Python subprocess module), and it keeps failing. Of course, the app works without problems when started manually. Starting the app from a Python-shell using [NSWorkspace launchApplication:] works, too. Just not from within the plug-in. If I'd have to guess I'd say that py2app doesn't fully reset the environment and some bits of the environment that py2app sets to communicate with the bundle code leaks into application bundle and causes problems there. What happens when you add "os.delenv('PYOBJC_BUNDLE_ADDRESS')" before you try to open the bundle? Ronald |
From: Robert K. <rob...@gm...> - 2011-11-22 15:50:42
|
Ronald Oussoren <ron...@ma...> wrote on Tue Nov 22 2011 at 16:44:55: > > What happens when you add "os.delenv('PYOBJC_BUNDLE_ADDRESS')" before you try to open the bundle? Great, that solves the problem! -- robert |
From: Ronald O. <ron...@ma...> - 2011-11-22 16:04:19
Attachments:
smime.p7s
|
On 22 Nov, 2011, at 16:50, Robert Klep wrote: > Ronald Oussoren <ron...@ma...> wrote on Tue Nov 22 2011 at 16:44:55: >> >> What happens when you add "os.delenv('PYOBJC_BUNDLE_ADDRESS')" before you try to open the bundle? > > Great, that solves the problem! Great to hear that. I've filed a bug in my py2app tracker (<https://bitbucket.org/ronaldoussoren/py2app/issue/33/py2app-should-clean-environment-better>) to ensure that I won't forget fixing this in a future release of py2app. Ronald > > -- robert > |