]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
osd/ECBackend: fix iterator invalidation in omap_get 70142/head
authorSun Yuechi <sunyuechi@iscas.ac.cn>
Mon, 13 Jul 2026 05:00:01 +0000 (22:00 -0700)
committerSun Yuechi <sunyuechi@iscas.ac.cn>
Mon, 13 Jul 2026 06:45:15 +0000 (14:45 +0800)
commit1dd8cb8bd54a4c954e1386cac8edc6a831aba5f1
tree9cac82a2d6ecfd931320031079d91c7021e935db
parent49ea86d184e775b42b5585c40ed70a83aacfc5e1
osd/ECBackend: fix iterator invalidation in omap_get

The removed_ranges erase loop in omap_get() called erase(out_it->first),
which invalidates out_it, then did ++out_it on the dead iterator (UB).
When adjacent keys were erased this skipped keys that should have been
removed:

    Expected: { "k01", "k05", "k06" }
    Actual:   { "k01", "k03", "k05", "k06" }

Extract the loop into a static remove_keys_in_ranges() helper so it can
be unit tested without an ObjectStore, and rewrite it as a range erase:
removed_ranges is a sorted map of non-overlapping [start, end) ranges.

Fixes: https://tracker.ceph.com/issues/78177
Signed-off-by: Sun Yuechi <sunyuechi@iscas.ac.cn>
src/osd/ECBackend.cc
src/osd/ECBackend.h
src/test/osd/test_ec_omap_journal.cc