pybind / pybind/pybind11

Leaking of C++ objects if they are constructed with a python function

Open
#1,278 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Issue description

C++ objects that take a python function as argument are not properly deleted. The issue seems to be that the Python garbage collector cannot break the reference cycle. I hope the example code illustrates the issue well. If there are any questions, you can also find me in the gitter.

Reproducible example code

yeganer/pybind11@d27b39e15d543fd8207d047ff1fe9fab52d9b440:test

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 reproducible example referenced at yeganer/pybind11@d27b39e15d543fd8207d047ff1fe9fab52d9b440:test, then inspect the related binding and ownership behavior in the repository. Confirm the failure involves Python garbage collection and reference cycles, and consider the issue done when the example no longer leaks constructed C++ objects.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
backend-api-design
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.