Closed
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
Problem description
After some tests on my Ubuntu 22, I remarked that pybind11 was crashing at the creation of a py::tuple or py::list object in my project.
Calling the function test() defined below causes a segmentation fault.
Crashes on:
- Ubuntu 22 with pybind11 2.9.2 and also 2.4.3
- Ubuntu 22 with pybind11 2.9.1 from distrib package
No crash on:
- Ubuntu 20 with pybind11 2.9.2 or 2.4.3
By looking deeper into the problem, I found out:
Using the policy py::call_guard<py::gil_scoped_release>() causes the crash. Without the policy it works well.
I tried different compilation options that all resulted in a crash.
To summarize:
The creation of a py::tuple or py::list object causes a crash on my Ubuntu 22 (gcc 11.2.0, Intel(R) Core(TM) i5-8500) with the policy py::call_guard<py::gil_scoped_release>().
Reproducible example code
.def_static("test", [] {
py::tuple tup = py::make_tuple(42, py::none(), "spam");
}, py::call_guard<py::gil_scoped_release>())