Skip to content

[BUG]: Creation of py::tuple or py::list causes a crash with policy py::call_guard<py::gil_scoped_release>() on Ubuntu 22 #4015

Description

@ylegoc

Required prerequisites

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>())

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions