]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PGLog: trim - avoid dereferencing invalid iter 23546/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Sat, 18 Aug 2018 09:17:01 +0000 (17:17 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Sat, 18 Aug 2018 09:18:24 +0000 (17:18 +0800)
Log(e.g., projected_log) could theoretically be emtpy and hence there might
be potential access violation.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/osd/PGLog.cc

index eb88dc1db3c52fc44557952dffbfdab108c9f6e2..0d9d73e598058b0b4c0c7eed23f9f8e981ea7c9c 100644 (file)
@@ -100,9 +100,13 @@ void PGLog::IndexedLog::trim(
 
     // reset complete_to to the beginning of the log
     if (reset_complete_to) {
-      lgeneric_subdout(cct, osd, 20) << " moving complete_to " << " to "
-                      << log.begin()->version << dendl;
       complete_to = log.begin();
+      if (complete_to != log.end()) {
+        lgeneric_subdout(cct, osd, 20) << " moving complete_to to "
+                                       << log.begin()->version << dendl;
+      } else {
+        lgeneric_subdout(cct, osd, 20) << " log is now empty" << dendl;
+      }
     }
   }