-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
triageNew bug, unverifiedNew bug, unverified
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
Problem description
The mere use of a subinterpreter leaks memory. Memory leaks were found with python 3.12 and 3.13 For example:
#include <pybind11/embed.h>
#include <pybind11/subinterpreter.h>
int main() {
pybind11::initialize_interpreter();
const auto sub_python = pybind11::subinterpreter::create();
}
From the pybind11 project source, I am building this minimal example with the following command
g++ test.cpp -fsanitize=address -I /usr/include/python3.13 -I ./include -l python3.13
Reference of g++ version:
g++ --version
g++ (GCC) 15.1.1 20250729
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The sanitizer's output is included as an attachment: sanitizer.txt
Reproducible example code
#include <pybind11/embed.h>
#include <pybind11/subinterpreter.h>
int main() {
pybind11::initialize_interpreter();
const auto sub_python = pybind11::subinterpreter::create();
}
Is this a regression? Put the last known working version here if it is.
Not a regression
Metadata
Metadata
Assignees
Labels
triageNew bug, unverifiedNew bug, unverified