You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
program sometimes core dump during destruction of scoped_interpreter,the error is as following:
terminate called after throwing an instance of 'std::runtime_error'
what(): pybind11::object_api<>::operator() PyGILState_Check() failure.
(the above message is from cast.h)
after checking the backtrace: Program terminated with signal SIGABRT, Aborted.
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
[Current thread is 1 (Thread 0x7f3ff7fff700 (LWP 8394))]
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 #1 0x00007f4023a00a8a in __GI_abort () at abort.c:89 #2 0x00007f4024336637 in __gnu_cxx::__verbose_terminate_handler () at ../../.././libstdc++-v3/libsupc++/vterminate.cc:95 #3 0x00007f40243420d6 in __cxxabiv1::__terminate (handler=)
at ../../.././libstdc++-v3/libsupc++/eh_terminate.cc:47 #4 0x00007f40243411d9 in __cxa_call_terminate (ue_header=ue_header@entry=0x7f3ff0009d30)
at ../../.././libstdc++-v3/libsupc++/eh_call.cc:54 #5 0x00007f4024341b04 in __cxxabiv1::__gxx_personality_v0 (version=, actions=6,
exception_class=5138137972254386944, ue_header=0x7f3ff0009d30, context=)
at ../../.././libstdc++-v3/libsupc++/eh_personality.cc:677 #6 0x00007f4023d928a3 in ?? () from /lib64/libgcc_s.so.1 #7 0x00007f4023d92dd7 in _Unwind_Resume () from /lib64/libgcc_s.so.1 #8 0x00007f40270df6c6 in pybind11::finalize_interpreter ()
I think the error is from here:
inline void finalize_interpreter ();
handle builtins(PyEval_GetBuiltins());
const char *id = PYBIND11_INTERNALS_ID;
// Get the internals pointer (without creating it if it doesn't exist). It's possible for the
// internals to be created during Py_Finalize() (e.g. if a py::capsule calls `get_internals()`
// during destruction), so we get the pointer-pointer here and check it after Py_Finalize().
detail::internals **internals_ptr_ptr = detail::get_internals_pp();
// It could also be stashed in builtins, so look there too:
**/******************* calls object_api<Derived>::operator() but PyGILState_Check() failure********************/**
if (builtins.contains(id) && isinstance<capsule>(builtins[id]))
internals_ptr_ptr = capsule(builtins[id]);
Py_Finalize();
if (internals_ptr_ptr) {
delete *internals_ptr_ptr;
*internals_ptr_ptr = nullptr;
}
the simple structure of my program is like this:
scoped_interptreter is a local static variable in shared.so,gil should be always hold by main thread, but somehow lost during finalizing?
// share.so
int InitScopedInterpreter()
{
static py::scoped_interpreter guard();
}
// main
int main(){
InitScopedInterpreter();
PyEval_InitThreads();
}
I tried to add PyGILState_Ensure() at the end of main(), but not work, Then I tried to add it in finalize_interpreter(), it works.
my question is:
why finalize_interpreter failed? because gil was accidently lost?
how to ensure gil is been hold during finalize_interpreter?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
program sometimes core dump during destruction of scoped_interpreter,the error is as following:
terminate called after throwing an instance of 'std::runtime_error'
what(): pybind11::object_api<>::operator() PyGILState_Check() failure.
(the above message is from cast.h)
after checking the backtrace:
Program terminated with signal SIGABRT, Aborted.
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
[Current thread is 1 (Thread 0x7f3ff7fff700 (LWP 8394))]
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007f4023a00a8a in __GI_abort () at abort.c:89
#2 0x00007f4024336637 in __gnu_cxx::__verbose_terminate_handler () at ../../.././libstdc++-v3/libsupc++/vterminate.cc:95
#3 0x00007f40243420d6 in __cxxabiv1::__terminate (handler=)
at ../../.././libstdc++-v3/libsupc++/eh_terminate.cc:47
#4 0x00007f40243411d9 in __cxa_call_terminate (ue_header=ue_header@entry=0x7f3ff0009d30)
at ../../.././libstdc++-v3/libsupc++/eh_call.cc:54
#5 0x00007f4024341b04 in __cxxabiv1::__gxx_personality_v0 (version=, actions=6,
exception_class=5138137972254386944, ue_header=0x7f3ff0009d30, context=)
at ../../.././libstdc++-v3/libsupc++/eh_personality.cc:677
#6 0x00007f4023d928a3 in ?? () from /lib64/libgcc_s.so.1
#7 0x00007f4023d92dd7 in _Unwind_Resume () from /lib64/libgcc_s.so.1
#8 0x00007f40270df6c6 in pybind11::finalize_interpreter ()
I think the error is from here:
inline void finalize_interpreter ();
the simple structure of my program is like this:
scoped_interptreter is a local static variable in shared.so,gil should be always hold by main thread, but somehow lost during finalizing?
// share.so
int InitScopedInterpreter()
{
static py::scoped_interpreter guard();
}
// main
int main(){
InitScopedInterpreter();
PyEval_InitThreads();
}
I tried to add PyGILState_Ensure() at the end of main(), but not work, Then I tried to add it in finalize_interpreter(), it works.
my question is:
Beta Was this translation helpful? Give feedback.
All reactions