[PyQt] Segfault when using QString as a function argument
phil at riverbankcomputing.com
Sat Sep 27 00:43:00 BST 2014
On 26/09/2014 8:25 pm, Will Ware wrote:
> I am trying to SIP-wrap some things, with various degrees of success,
> new to the whole Qt4/PyQt/SIP world. I'm on a Mac. The issue I am
> into is in trying to wrap a pretty simple C++ function, which looks
> bool InitializeApplication(QString applicationName);
You don't say but I'm assuming Python3 rather than Python2.
That particular argument declaration is extremely rare as far as PyQt is
concerned - so may be buggy.
Unless the function is going to modify applicationName then you would
expect it to be const QString& (which is a very common declaration).
Can you change your .sip file and the library you are wrapping to use
const QString&? If the problem goes away then it's a PyQt bug. If not
then it's likely to be a bug in your .sip files.
> 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 +
> 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 +
> 9 org.python.python 0x000000010d7f5c2c 0x10d757000 +
> 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
> to convert a native type (such as QString, in this instance) to a
> object, and the function being pointed to is somehow incompatible with
> code I compiled myself.
> Has anybody run into anything like this? Any suggestions for a
> avenue of investigation?
> Thanks very much,
> Will Ware
> PyQt mailing list PyQt at riverbankcomputing.com
More information about the PyQt