Skip to content

Commit

Permalink
librbd: avoid decrementing iterator before first element
Browse files Browse the repository at this point in the history
While trying to merge delayed requests, SimpleSchedulerObjectDispatch
can end up iterating before the first element.

With llvm, this leads to a crash:
https://paste.opendev.org/raw/bxnQqqDtIrkOfVvRfkZ6/

This change adds a check, ensuring that we won't decrement the iterator
before the first map element.

Tracker issue: https://tracker.ceph.com/issues/61503

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
  • Loading branch information
petrutlucian94 committed May 30, 2023
1 parent d2205f5 commit 9d21a32
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librbd/io/SimpleSchedulerObjectDispatch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ bool SimpleSchedulerObjectDispatch<I>::ObjectRequests::try_delay_request(

// try to merge back to an existing request
iter = m_delayed_requests.lower_bound(object_off);
if (iter == m_delayed_requests.end() || iter->first > object_off) {
if (iter != m_delayed_requests.begin() &&
(iter == m_delayed_requests.end() || iter->first > object_off)) {
iter--;
}
if (iter != m_delayed_requests.end() &&
Expand Down

0 comments on commit 9d21a32

Please sign in to comment.