pybind / pybind11

Seamless operability between C++11 and Python
https://pybind11.readthedocs.io/
Other
15.55k stars 2.09k forks source link

[BUG]: crash importing again same module #5080

Open yobiminds opened 6 months ago

yobiminds commented 6 months ago

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

1.12.0

Problem description

Restarting an embedded interpreter gives crash when importing a module the second time.

A breakpoint instruction (__debugbreak() statement or a similar call) was executed in test.exe.

Some modules, like 'sys' or 'os', work fine.

Reproducible example code

int main() {

    py::initialize_interpreter();
    py::module_::import("numpy");  //--> it works fine with modules like 'sys', 'os'. 
    py::finalize_interpreter();

    py::initialize_interpreter();
    py::module_::import("numpy"); //--> crash here
    py::finalize_interpreter();
    return 0;
}

Is this a regression? Put the last known working version here if it is.

Not aware if this is a regression