From: John Spray Date: Tue, 17 Oct 2017 22:14:43 +0000 (-0400) Subject: mgr: fix ~MonCommandCompletion X-Git-Tag: v12.2.2~61^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2a94381b53241f9ecb98c4cc605ef6547b910ca2;p=ceph.git mgr: fix ~MonCommandCompletion This was doing a Py_DECREF outside of the Gil. Fixes: http://tracker.ceph.com/issues/21593 Signed-off-by: John Spray (cherry picked from commit 58dfa97ba88882fb3540d15e31bcac48a1aef5ef) --- diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 6f7252e86b15..95e75492c932 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -64,11 +64,19 @@ public: ~MonCommandCompletion() override { - Py_DECREF(python_completion); + if (python_completion) { + // Usually do this in finish(): this path is only for if we're + // being destroyed without completing. + Gil gil(pThreadState, true); + Py_DECREF(python_completion); + python_completion = nullptr; + } } void finish(int r) override { + assert(python_completion != nullptr); + dout(10) << "MonCommandCompletion::finish()" << dendl; { // Scoped so the Gil is released before calling notify_all() @@ -92,6 +100,10 @@ public: Py_DECREF(rtn); } Py_DECREF(args); + Py_DECREF(set_fn); + + Py_DECREF(python_completion); + python_completion = nullptr; } py_modules->notify_all("command", tag); }