Skip to content

Commit b147430

Browse files
committed
Hold GIL before decref
1 parent 1d49006 commit b147430

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/pybind11/detail/internals.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ struct internals {
345345
// original owning interpreter is active.
346346
auto *cur_istate = get_interpreter_state_unchecked();
347347
if (cur_istate && cur_istate == istate) {
348+
gil_scoped_acquire_simple gil;
348349
Py_CLEAR(instance_base);
349350
Py_CLEAR(default_metaclass);
350351
Py_CLEAR(static_property_type);
@@ -378,6 +379,7 @@ struct local_internals {
378379
// original owning interpreter is active.
379380
auto *cur_istate = get_interpreter_state_unchecked();
380381
if (cur_istate && cur_istate == istate) {
382+
gil_scoped_acquire_simple gil;
381383
Py_CLEAR(function_record_py_type);
382384
}
383385
}
@@ -877,6 +879,7 @@ inline local_internals &get_local_internals() {
877879
auto &ppmgr = get_local_internals_pp_manager();
878880
auto &internals_ptr = *ppmgr.get_pp();
879881
if (!internals_ptr) {
882+
gil_scoped_acquire_simple gil;
880883
internals_ptr.reset(new local_internals());
881884
}
882885
return *internals_ptr;

0 commit comments

Comments
 (0)