[PyQt] Segfault when using QString as a function argument

Will Ware ware at formlabs.com
Fri Sep 26 20:25:47 BST 2014

I am trying to SIP-wrap some things, with various degrees of success, being
new to the whole Qt4/PyQt/SIP world. I'm on a Mac. The issue I am running
into is in trying to wrap a pretty simple C++ function, which looks like

bool InitializeApplication(QString applicationName);

The issue appears to be some kind of mismatch (toolchain? Qt version?
I'm not sure) between the Qt library which would define a SIP wrapper
for QString, and my own stuff. The error message looks like this.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   ???                           0x000000bb0000024d 0 + 803158884941
1   sip.so                         0x000000010ebc4140
sip_api_convert_to_type + 245
2   sip.so                         0x000000010ebce0b5 parsePass2 + 3985
3   sip.so                         0x000000010ebcadb6 parseKwdArgs + 322
4   sip.so                         0x000000010ebc81f9 sip_api_parse_args +
5   etools.so                     0x000000010db50ee4
func_InitializeApplication(_object*, _object*) + 116
6   org.python.python             0x000000010d7d914d PyEval_EvalFrameEx +
7   org.python.python             0x000000010d7d7093 PyEval_EvalCodeEx +
8   org.python.python             0x000000010d7d6a24 PyEval_EvalCode + 54
9   org.python.python             0x000000010d7f5c2c 0x10d757000 + 650284
10  org.python.python             0x000000010d7f5cd3 PyRun_FileExFlags + 137
11  org.python.python             0x000000010d7f5821
PyRun_SimpleFileExFlags + 718
12  org.python.python             0x000000010d806363 Py_Main + 2995
13  libdyld.dylib                 0x00007fff8830d5fd start + 1

Apparently the Mac is a GDB-hostile platform, so I've relied on print
statements to learn that there is a field called "mtd_cto" defined in
siplib/sip.h as part of sipMappedTypeDef, which is a function pointer used
to convert a native type (such as QString, in this instance) to a Python
object, and the function being pointed to is somehow incompatible with the
code I compiled myself.

Has anybody run into anything like this? Any suggestions for a productive
avenue of investigation?

Thanks very much,
Will Ware
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140926/3535b2b5/attachment-0001.html>

More information about the PyQt mailing list