[BUG] calling multiple pybind11 scoped env which calls cppyy
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 28/100
Línea de trabajo
Reproduce la segunda invocación de Test002 en main.cpp, especialmente alrededor de las líneas 32 y 147, utilizando la configuración mostrada de Python embebido y cppyy. Lee pybind11::exec y pybind11::eval en eval.h junto con el trace del fallo. Se considera completado cuando la misma operación puede llamarse varias veces sin el aborto invalid-size indicado, con una comprobación de regresión para llamadas repetidas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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?
2.13.6
Problem description
i have embedded python with my QT (c++) solution. i call a c++ function which uses pybind11 to get me into python, which in turn sets up a cppyy encapsualtion of a simpe c++ function. it works fine, but call it again it crashes. below is the crash report
"
Hello, World!
['/home/simon/Desktop/Code/VirtEnv/lib/python3.12/site-packages/', '/home/simon/Code/QT/Test_pybind11/Test_pybind11_cppyy_001/', '', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/usr/local/lib/python3.12/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.12/dist-packages']
here
there
done
free(): invalid size
*** Break *** abort
#0 0x00007f9cb8710893 in __GI___wait4 (pid=4609, stat_loc=stat_loc
entry=0x7fff23a04f68, options=options
entry=0, usage=usage
entry=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
#1 0x00007f9cb87109e7 in __GI___waitpid (pid=, stat_loc=stat_loc
entry=0x7fff23a04f68, options=options
entry=0) at ./posix/waitpid.c:38
#2 0x00007f9cb866891b in do_system (line=) at ../sysdeps/posix/system.c:172
#3 0x00007f9cb5ba1c15 in CppyyLegacy::TUnixSystem::StackTrace() () from /home/simon/Desktop/Code/VirtEnv/lib/python3.12/site-packages/cppyy_backend/lib/libCoreLegacy.so
#4 0x00007f9cb5cd94bf in (anonymous namespace)::do_trace (sig=5) at src/clingwrapper.cxx:249
#5 (anonymous namespace)::TExceptionHandlerImp::HandleException (this=, sig=5) at src/clingwrapper.cxx:262
.....
#42 0x00007f9cb8ef0ae6 in ?? () from /lib/x86_64-linux-gnu/libpython3.12.so.1.0
#43 0x00007f9cb8ef0bf9 in ?? () from /lib/x86_64-linux-gnu/libpython3.12.so.1.0
#44 0x00007f9cb8ef41bf in PyRun_StringFlags () from /lib/x86_64-linux-gnu/libpython3.12.so.1.0
#45 0x000055ea7e523055 in pybind11::eval<(pybind11::eval_mode)2> (expr=..., global=..., local=...) at /usr/include/pybind11/eval.h:74
#46 0x000055ea7e4fcb2b in pybind11::exec (expr=..., global=..., local=...) at /usr/include/pybind11/eval.h:89
#47 0x000055ea7e4fb462 in Test002 () at /home/simon/Code/QT/Test_pybind11/Test_pybind11_cppyy_001/main.cpp:147
#48 0x000055ea7e4fb1bb in main (argc=1, argv=0x7fff23a09058) at /home/simon/Code/QT/Test_pybind11/Test_pybind11_cppyy_001/main.cpp:32
*** Break *** abort
#0 0x00007f9cb8710893 in __GI___wait4 (pid=4848, stat_loc=stat_loc
entry=0x7fff23a04f68, options=options
entry=0, usage=usage
entry=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
#1 0x00007f9cb87109e7 in __GI___waitpid (pid=, stat_loc=stat_loc
entry=0x7fff23a04f68, options=options
entry=0) at ./posix/waitpid.c:38
#2 0x00007f9cb866891b in do_system (line=) at ../sysdeps/posix/system.c:172
#3 0x00007f9cb5ba1c15 in CppyyLegacy::TUnixSystem::StackTrace() () from /home/simon/Desktop/Code/VirtEnv/lib/python3.12/site-packages/cppyy_backend/lib/libCoreLegacy.so
#4 0x00007f9cb5cd93cf in (anonymous namespace)::do_trace (sig=5) at src/clingwrapper.cxx:249
#5 (anonymous namespace)::TExceptionHandlerImp::HandleException (this=, sig=5) at src/clingwrapper.cxx:268
....
#41 0x00007f9cb8e97507 in PyEval_EvalCode () from /lib/x86_64-linux-gnu/libpython3.12.so.1.0
#42 0x00007f9cb8ef0ae6 in ?? () from /lib/x86_64-linux-gnu/libpython3.12.so.1.0
#43 0x00007f9cb8ef0bf9 in ?? () from /lib/x86_64-linux-gnu/libpython3.12.so.1.0
#44 0x00007f9cb8ef41bf in PyRun_StringFlags () from /lib/x86_64-linux-gnu/libpython3.12.so.1.0
#45 0x000055ea7e523055 in pybind11::eval<(pybind11::eval_mode)2> (expr=..., global=..., local=...) at /usr/include/pybind11/eval.h:74
#46 0x000055ea7e4fcb2b in pybind11::exec (expr=..., global=..., local=...) at /usr/include/pybind11/eval.h:89
#47 0x000055ea7e4fb462 in Test002 () at /home/simon/Code/QT/Test_pybind11/Test_pybind11_cppyy_001/main.cpp:147
#48 0x000055ea7e4fb1bb in main (argc=1, argv=0x7fff23a09058) at /home/simon/Code/QT/Test_pybind11/Test_pybind11_cppyy_001/main.cpp:32
13:33:11: /home/simon/Code/QT/Test_pybind11/Test_pybind11_cppyy_001/build/Desktop_Qt_6_7_2-Debug/Test_pybind11_cppyy_001 exited with code 133
"
when run from with a debugger:
"
Hello, World!
['/home/simon/Desktop/Code/VirtEnv/lib/python3.12/site-packages/', '/home/simon/Code/QT/Test_pybind11/Test_pybind11_cppyy_001/', '', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/usr/local/lib/python3.12/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.12/dist-packages']
here
there
done
free(): invalid size
44 ./nptl/pthread_kill.c: No such file or directory
81 ../sysdeps/unix/sysv/linux/internal-signals.h: No such file or directory
50 ./nptl/pthread_kill.c: No such file or directory
89 ../sysdeps/unix/sysv/linux/internal-signals.h: No such file or directory
69 ./nptl/pthread_kill.c: No such file or directory
"
Reproducible example code
as called from my QT solution:
"
//
void Test002()
{
//
py::scoped_interpreter guard{};
//
QString qPythonDir("/home/simon/Code/QT/Test_pybind11/Test_pybind11_cppyy_001/");
QString qPythonCommand("");
//
auto locals = py::dict();
auto globals = py::dict();
//
qPythonCommand += "import sys\n";
qPythonCommand += "sys.path.insert(0, '";
qPythonCommand += qPythonDir.toStdString().c_str();
qPythonCommand += "')\n";
qPythonCommand += "sys.path.insert(0, '/home/simon/Desktop/Code/VirtEnv/lib/python3.12/site-packages/')\n";
qPythonCommand += "print(sys.path)\n";
py::exec(qPythonCommand.toStdString().c_str(), py::globals(), locals);
//
qPythonCommand =
R"PY(
import cppyy
cppyy.cppdef("""
#include
void hello()
{
std::cout << "Hello, World!" << std::endl;
}
""")
def runCPP():
global cppyy
print("here")
try:
cppyy.gbl.hello()
print("there")
except Exception as e:
print("Exception: ", e)
print("done")
)PY";
//
py::exec(qPythonCommand.toStdString().c_str(), py::globals(), locals);
//
py::object func = locals["runCPP"];
func();
//
}
"
similar idea to above, but this time no pybind11 and directly from with python. works multiple times.
"
import cppyy
cppyy.cppdef(r"""
#include
void hello() {
std::cout << "Hello, World!" << std::endl;
}
""")
def runCPP():
print("here")
try:
cppyy.gbl.hello()
print("there")
except Exception as e:
print("Exception: ", e)
print("done")
"
Is this a regression? Put the last known working version here if it is.
Not a regression
- Lenguaje dominante
- C++
- Estrellas
- 18k
- Forks
- 2.3k
- Merge medio
- 5 d 7 h
- PR fusionados (30 d)
- 53
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pybind/pybind11
-
triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 3 días
-
triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
pybind/pybind11#5604 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 3 días
-
docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 60/100
pybind/pybind11#747 · 2 comentarios ·
Los mantenedores suelen responder en 3 días
-
array_t::at() returns a misaligned reference when the stride is not a multiple of alignof(T)Posiblemente ocupada @henryiii la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 3 días
Todos los issues de pybind/pybind11
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
patrick-hudson/put.gd-desktop#2044 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
uxlfoundation/oneDNN#6604 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
[Bug]: RoundToNearest truncates in plugins compiled with spcomp 1.13Posiblemente ocupada @fmu1337 la tomó hoy. AbiertoBug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
alliedmodders/sourcemod#2627 ·
Los mantenedores suelen responder en 1 día
-
`Number` enum is not exportedAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día