strange problem using NSWorkspace/NSTask to start PyObjC apps

Robert Klep <[email protected]>
Newsgroups gmane.comp.python.pyobjc.devel
Message-ID <[email protected]>
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


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.