From 50523a225b2f415b8c3d82faeae59c0eede54663 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 11 Aug 2017 11:58:42 -0400 Subject: [PATCH] os/bluestore: do not segv on kraken upgrade debug print When loading an onode from kraken we have a compat path that calls get_ref before the SharedBlob pointer is initialized. This is fine except that if debugging is enabled the operator<< on the Blob will segv on printing *b.shared_blob (which is NULL). Fix operator<< to print something else if it is NULL. shared_blob does get set up right after the call to decode() so having it be NULL at this point is otherwise harmless. Fixes: http://tracker.ceph.com/issues/20977 Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 40e152bcce975..c095ef186f7a0 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1703,9 +1703,13 @@ ostream& operator<<(ostream& out, const BlueStore::Blob& b) if (b.is_spanning()) { out << " spanning " << b.id; } - out << " " << b.get_blob() << " " << b.get_blob_use_tracker() - << " " << *b.shared_blob - << ")"; + out << " " << b.get_blob() << " " << b.get_blob_use_tracker(); + if (b.shared_blob) { + out << " " << *b.shared_blob; + } else { + out << " (shared_blob=NULL)"; + } + out << ")"; return out; } -- 2.39.5