From efcb708e173c864e887b39e7ca77d01ab37248ee Mon Sep 17 00:00:00 2001 From: ningtao Date: Thu, 3 Jan 2019 23:20:12 +0800 Subject: [PATCH] mon: shutdown messenger early to avoid accessing deleted logger In the monitor shutdown process, the MSG thread exits after the logger is released, causing the null pointer to be accessed. So move the logger release to the MSG thread after it exits Fixes: http://tracker.ceph.com/issues/37780 Signed-off-by: ningtao (cherry picked from commit 47da5a0caa7edec17ff4253e363571b78372506a) --- src/mon/Monitor.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index a1d0217935aea..921c74868d5c0 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -963,6 +963,16 @@ void Monitor::shutdown() remove_all_sessions(); + log_client.shutdown(); + + // unlock before msgr shutdown... + lock.Unlock(); + + // shutdown messenger before removing logger from perfcounter collection, + // otherwise _ms_dispatch() will try to update deleted logger + messenger->shutdown(); + mgr_messenger->shutdown(); + if (logger) { cct->get_perfcounters_collection()->remove(logger); delete logger; @@ -974,14 +984,6 @@ void Monitor::shutdown() delete cluster_logger; cluster_logger = NULL; } - - log_client.shutdown(); - - // unlock before msgr shutdown... - lock.Unlock(); - - messenger->shutdown(); // last thing! ceph_mon.cc will delete mon. - mgr_messenger->shutdown(); } void Monitor::wait_for_paxos_write() -- 2.39.5