From 58dfa97ba88882fb3540d15e31bcac48a1aef5ef Mon Sep 17 00:00:00 2001 From: John Spray Date: Tue, 17 Oct 2017 18:14:43 -0400 Subject: [PATCH] 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 --- src/mgr/BaseMgrModule.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 6f7252e86b159..95e75492c932f 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); } -- 2.39.5