Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit 04c3119

Browse files
xinghuadou-googleXinghua Dou
authored andcommitted
Don't decrement reference count if Python is not running.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190131752
1 parent 81396e3 commit 04c3119

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/googleclouddebugger/python_util.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ class ScopedPyObjectT {
6969
}
7070

7171
~ScopedPyObjectT() {
72-
reset(nullptr);
72+
// Only do anything if Python is running. If not, we get might get a
73+
// segfault when we try to decrement the reference count of the underlying
74+
// object when this destructor is run after Python itself has cleaned up.
75+
// https://bugs.python.org/issue17703
76+
if (Py_IsInitialized()) {
77+
reset(nullptr);
78+
}
7379
}
7480

7581
static ScopedPyObjectT NewReference(TPointer* obj) {

0 commit comments

Comments
 (0)