]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/bufferlist: avoid BenchDeref iterator overrun past end
authorSun Yuechi <sunyuechi@iscas.ac.cn>
Tue, 23 Jun 2026 10:18:25 +0000 (18:18 +0800)
committerSun Yuechi <sunyuechi@iscas.ac.cn>
Wed, 24 Jun 2026 03:44:05 +0000 (11:44 +0800)
Drive the deref loop by get_remaining() >= step instead of comparing to
end(), so a total length that is not a multiple of step no longer lets
`iter += step` run past the end and throw "End of buffer".

The original counts were always a multiple of step, so the overrun only
showed up once the following commit shrinks the rounds under ASan -- a
false alarm rather than a real regression, which is why it went unnoticed
until now.

Signed-off-by: Sun Yuechi <sunyuechi@iscas.ac.cn>
src/test/bufferlist.cc

index ba83f532934437898ccab65fa5c553164b433728..41b47c6102967df09a43a71878cb552d0b1fd134 100644 (file)
@@ -823,7 +823,7 @@ static void bench_bufferlistiter_deref(const size_t step,
 
   utime_t start = ceph_clock_now();
   bufferlist::iterator iter = bl.begin();
-  while (iter != bl.end()) {
+  while (iter.get_remaining() >= step) {
     iter += step;
   }
   utime_t end = ceph_clock_now();