Skip to content

Crash when importing torch #1472

Description

@pasbi

Issue description

My application crashes when pybind11::scoped_interpreter is destructed after importing torch.

Reproducible example code

#include <pybind11/embed.h>
int main()
{
pybind11::scoped_interpreter guard{};
pybind11::exec("import torch");
// pybind11::module::import("torch"); // same problem
}

Note that the import itself works like a charm.
In the real code, I am using torch and it does what it is supposed to do.
The crash occurs when guard goes out of scope, i.e., when it is destructed.

I guess it's a double-free issue, however, I can't narrow down the problem in torch, I believe the problem is somewhere deep in its C-implementation. Importing tensorflow, numpy, matplotlib and other modules does not make such trouble.
I already asked in the gitter lobby, but I didn't get an answer.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions