pybind / pybind/pybind11

[BUG]: Pybind11 crashes on cleanup in GCC 7.4 and 7.5

Open
#3,814 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triage
Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

Required prerequisites
Problem description

Pybind consistently fails to clean up after itself if I have imported Pytorch.

When shutting down the interpreter, whether manually or via the scoped interpreter leaving scope, Pybind tries to free memory that has already been freed and crashes.

I'm using the latest stable version of pybind and GCC 7.5. The problem does not manifest in GCC 4.8.5.

More information in the example code project

Reproducible example code
https://github.com/Sleemanmunk/pybind_crash

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproducible example project and reproduce cleanup during interpreter shutdown after importing PyTorch, both manually and through the scoped interpreter. Compare behavior on GCC 7.4/7.5 and GCC 4.8.5, then trace the cleanup path; done means the example no longer crashes while shutting down.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python, pytorch
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.