Bug 2252083 - pybind11 fails with Python 3.13: Objects/dictobject.c:5473: _PyObject_InitInlineValues: Assertion `keys != NULL' failed.
Summary: pybind11 fails with Python 3.13: Objects/dictobject.c:5473: _PyObject_InitInl...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: pybind11
Version: 40
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Susi Lehtola
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.13
TreeView+ depends on / blocked
 
Reported: 2023-11-29 11:49 UTC by Miro Hrončok
Modified: 2024-06-19 15:10 UTC (History)
7 users (show)

Fixed In Version:
Clone Of:
: 2293099 (view as bug list)
Environment:
Last Closed: 2024-06-19 15:10:53 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Package Sources pybind11 pull-request 10 0 None None None 2023-12-13 16:12:27 UTC
Github pybind pybind11 pull 4971 0 None open fix: make_static_property_type() 2023-12-13 16:12:27 UTC

Description Miro Hrončok 2023-11-29 11:49:37 UTC
python-contourpy fails to build with Python 3.13.0a2.

The failure is:

+ /usr/bin/pytest -k 'not image'
/var/tmp/rpm-tmp.qj4E8r: line 53:   742 Segmentation fault      (core dumped) CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" PATH="/builddir/build/BUILDROOT/python-contourpy-1.2.0-2.fc40~bootstrap.x86_64/usr/bin:$PATH" PYTHONPATH="${PYTHONPATH:-/builddir/build/BUILDROOT/python-contourpy-1.2.0-2.fc40~bootstrap.x86_64/usr/lib64/python3.13/site-packages:/builddir/build/BUILDROOT/python-contourpy-1.2.0-2.fc40~bootstrap.x86_64/usr/lib/python3.13/site-packages}" PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} --ignore=/builddir/build/BUILD/contourpy-1.2.0/.pyproject-builddir" PYTEST_XDIST_AUTO_NUM_WORKERS=4 /usr/bin/pytest -k 'not image'


When debugging the failure, I added:

  BuildRequires:  python3-debug
  ...
  %check
  %{py3_test_envvars} python3-debug -c 'import contourpy'


And I got:

+ python3-debug -c 'import contourpy'
python3-debug: /builddir/build/BUILD/Python-3.13.0a2/Objects/dictobject.c:5473: _PyObject_InitInlineValues: Assertion `keys != NULL' failed.

RPM build errors:
/var/tmp/rpm-tmp.agBjMb: line 53:   564 Aborted                 (core dumped) CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" PATH="/builddir/build/BUILDROOT/python-contourpy-1.2.0-2.fc40~bootstrap.x86_64/usr/bin:$PATH" PYTHONPATH="${PYTHONPATH:-/builddir/build/BUILDROOT/python-contourpy-1.2.0-2.fc40~bootstrap.x86_64/usr/lib64/python3.13/site-packages:/builddir/build/BUILDROOT/python-contourpy-1.2.0-2.fc40~bootstrap.x86_64/usr/lib/python3.13/site-packages}" PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} --ignore=/builddir/build/BUILD/contourpy-1.2.0/.pyproject-builddir" PYTEST_XDIST_AUTO_NUM_WORKERS=8 python3-debug -c 'import contourpy'



I suspect this is caused by a problem in pybind11. I wanted to report this upstream somewhere, but reproducing outside of RPM environment is currently very hard due to problems in meson (patch-fixed in Fedora).






For all our attempts to build python-contourpy with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/python-contourpy/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.13:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Elliott Sales de Andrade 2023-11-29 13:06:07 UTC
I'm pretty sure this is going to be a pybind11 issue; I don't think contourpy has any Python API calls in it.

Comment 2 Victor Stinner 2023-12-13 15:08:57 UTC
It's a bug in pybind11: the pybind11_static_property type is initialized (by PyType_Ready()) without Py_TPFLAGS_MANAGED_DICT, and *then* pybind11 sets the Py_TPFLAGS_MANAGED_DICT flag on the type. The flag should be set *before calling PyType_Ready(). Maybe it worked on Python 3.12, but in Python 3.13, it's now a bug.

In pybind11/include/pybind11/detail/class.h, make_static_property_type() creates the heap type "pybind11_static_property", calls PyType_Ready(), and only later calls enable_dynamic_attributes() which sets Py_TPFLAGS_MANAGED_DICT flag.

Comment 3 Victor Stinner 2023-12-13 15:13:30 UTC
I reported the issue upstream: https://github.com/pybind/pybind11/issues/4970

Comment 5 Miro Hrončok 2023-12-13 16:27:26 UTC
I'm moving this bugzilla to pybind11.

It has been built in our copr with the patch, but I'd wait with merging before we hear from upstream (or at least to January).

Comment 6 Aoife Moloney 2024-02-15 23:06:23 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 40 development cycle.
Changing version to 40.


Note You need to log in before you can comment on or make changes to this bug.