Python 3.14a7: Segfault in sip_api_init_module / _Py_TYPE

Phil Thompson phil at riverbankcomputing.com
Sun Apr 13 11:42:06 BST 2025


On 13/04/2025 10:45, Florian Bruhin wrote:
> On 2025-04-13T09:21:41 , Phil Thompson wrote:
>> 
>> On 12/04/2025 21:13, Florian Bruhin wrote:
>> > On 2025-04-11T20:57:32 , Phil Thompson wrote:
>> >>
>> >> On 11/04/2025 16:15, Florian Bruhin wrote:
>> >> > Hey,
>> >> >
>> >> > PyQt6 6.9.0 seemed to work fine with Python 3.14 Alpha 6 so far.
>> >> > However, after upgrading to Alpha 7, "from PyQt6.QtCore" immediately
>> >> > segfaults:
>> >> >
>> >> >     [...]
>> >> >
>> >> > I bisected this to this change in CPython, "Cache the result of
>> >> > tuple_hash", which adds a new ob_hash field to PyTupleObject:
>> >> >
>> >> > https://github.com/python/cpython/pull/131529
>> >> > https://github.com/python/cpython/commit/8614f86b7163b1c39798b481902dbb511292a537
>> >> >
>> >> > I'm not sure what happens there under the hood. Is there anything
>> >> > special PyQt/sip is doing there, or is this simply some sort of CPython
>> >> > regression in that commit? Happy to report it there, but I don't know
>> >> > much about the CPython C API at all.
>> >> >
>> >> > Florian
>> >>
>> >> Just by visual inspection of the code, I think the sequence of calls
>> >> is...
>> >>
>> >> [...]
>> >>
>> >> ...so I don't think I'm doing anything bad.
>> >>
>> >> Phil
>> >
>> > Thanks, I opened a CPython issue here:
>> > https://github.com/python/cpython/issues/132454
>> >
>> > Florian
>> 
>> A quick check - I assume you are building PyQt6.sip from source 
>> against
>> the Alpha 7 headers.
> 
> I just tried rebuilding PyQt6-sip just to be sure:
> https://bpa.st/SPHQ
> 
> Still seeing the same issue with that though.
> 
> I also tried rebuilding PyQt itself from sources, but that fails with:
> 
>     g++ -c -pipe -O2 -fno-exceptions -Wall -Wextra
> -mno-direct-extern-access -D_REENTRANT -fPIC -DSIP_PROTECTED_IS_PUBLIC
> -Dprotected=public -DQT_KEYPAD_NAVIGATION -DQT_NO_EXCEPTIONS
> -DQT_NO_DEBUG -DQT_PLUGIN -DQT_CORE_LIB -I. -I. -I..
> -I/home/florian/tmp/pyqt-src/pyqt6-6.9.0/qpy/QtCore
> -I/usr/local/include/python3.14d -I/usr/include/qt6
> -I/usr/include/qt6/QtCore -I. -I/usr/lib/qt6/mkspecs/linux-g++ -o
> sipQtCorecmodule.o sipQtCorecmodule.cpp
>     In file included from sipAPIQtCore.h:29,
>                      from sipQtCorecmodule.cpp:24:
>     ../sip.h:14:10: fatal error: Python.h: No such file or directory
> 
> Can I somehow easily teach it to pass
> -I/home/florian/proj/cpython/Include/ so I don't need to actually
> install the Python dev build I'm testing against?

I'm not sure what you mean. The sip module does not use the limited ABI 
and so must be built against the appropriate Python version.

Re-building PyQt6 won't make any difference.

The bug is what you would get if you were using the PyTuple_GET_ITEM 
macro from a pre-alpha7 header file against an alpha7 installation.

Phil


More information about the PyQt mailing list