]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: avoid null deref in Monitor::_mon_status()
authorSage Weil <sage@inktank.com>
Fri, 3 May 2013 23:04:31 +0000 (16:04 -0700)
committerSage Weil <sage@inktank.com>
Fri, 3 May 2013 23:04:31 +0000 (16:04 -0700)
mikedawson reports:

*** Caught signal (Segmentation fault) **
 in thread 7f40ce270700

 ceph version 0.60-801-g7ec0151 (7ec01513970b5a977bdbdf60052b6f6e257d267e)
 1: /usr/bin/ceph-mon() [0x59d550]
 2: (()+0xfbd0) [0x7f40d3e38bd0]
 3: (operator<<(std::ostream&, entity_name_t const&)+0x16) [0x4d7c46]
 4: (operator<<(std::ostream&, entity_inst_t const&)+0x1b) [0x4d837b]
 5: (Monitor::_mon_status(std::ostream&)+0x2ce) [0x4d284e]
 6: (Monitor::do_admin_command(std::string, std::string, std::ostream&)+0x4f) [0x4d652f]
 7: (AdminHook::call(std::string, std::string, ceph::buffer::list&)+0x68) [0x4efa38]
 8: (AdminSocket::do_accept()+0x451) [0x64ab81]
 9: (AdminSocket::entry()+0x398) [0x64c528]
 10: (()+0x7f8e) [0x7f40d3e30f8e]
 11: (clone()+0x6d) [0x7f40d237ae1d]

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/mon/Monitor.cc

index b9afa4265d8fc7397cea662c4c3a9883b86371c2..56cd291cd24ae8035bfd04b23870502ecffc25f4 100644 (file)
@@ -2287,8 +2287,14 @@ void Monitor::_mon_status(ostream& ss)
   jf.close_section();
 
   if (is_synchronizing()) {
-    jf.dump_stream("sync_leader") << sync_leader->entity;
-    jf.dump_stream("sync_provider") << sync_provider->entity;
+    if (sync_leader)
+      jf.dump_stream("sync_leader") << sync_leader->entity;
+    else
+      jf.dump_string("sync_leader", "");
+    if (sync_provider)
+      jf.dump_stream("sync_provider") << sync_provider->entity;
+    else
+      jf.dump_string("sync_provider", "");
   }
 
   jf.open_object_section("monmap");