From cbd22c7ba227440ac7e25a15cbd4a1a6c5c00687 Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Sat, 2 Nov 2024 10:01:52 +0800 Subject: [PATCH] crimson/osd/pg: fix dangerous lambda captures In PG::submit_transaction(), osd_op_p was first moved to ReplicatedBackend::submit_transaction(), and later its at_version is captured in another lambda. The latter may be already empty at the time of the capture. Signed-off-by: Xuehan Xu --- src/crimson/osd/pg.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index de39fb45716..e2cdd09bb09 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -924,8 +924,9 @@ PG::submit_transaction( } epoch_t map_epoch = get_osdmap_epoch(); + auto at_version = osd_op_p.at_version; - peering_state.pre_submit_op(obc->obs.oi.soid, log_entries, osd_op_p.at_version); + peering_state.pre_submit_op(obc->obs.oi.soid, log_entries, at_version); peering_state.update_trim_to(); ceph_assert(!log_entries.empty()); @@ -947,8 +948,8 @@ PG::submit_transaction( co_return std::make_tuple( std::move(submitted), all_completed.then_interruptible( - [this, last_complete=peering_state.get_info().last_complete, - at_version=osd_op_p.at_version](auto acked) { + [this, at_version, + last_complete=peering_state.get_info().last_complete](auto acked) { for (const auto& peer : acked) { peering_state.update_peer_last_complete_ondisk( peer.shard, peer.last_complete_ondisk);