Skip to content

Commit

Permalink
crimson/osd/pg: fix dangerous lambda captures
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
xxhdx1985126 committed Nov 12, 2024
1 parent 1c93566 commit cbd22c7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/crimson/osd/pg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
Expand Down

0 comments on commit cbd22c7

Please sign in to comment.