Skip to content

osd: Fix use of undefined end() iterator in proc_master_log - #71595

Closed
JonBailey1993 wants to merge 1 commit into
ceph:mainfrom
JonBailey1993:fix_undefined_iterator_access
Closed

JonBailey1993 wants to merge 1 commit into
ceph:mainfrom
JonBailey1993:fix_undefined_iterator_access

Conversation

@JonBailey1993

@JonBailey1993 JonBailey1993 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

osd: Fix use of undefined end() iterator in proc_master_log

In proc_master_log, we need to decide when to call consider_adjusting_pwlc(...). We do this by comparing the incoming log from a message against our own log. We use an iterator pointing at the end of the incoming log and compare it to our own log in various ways to determine if we need to adjust the pwlc values. For all non-empty cases, we were comparing olog.log.end()->version with p->version, where accessing olog.log.end() results in undefined behaviour (https://en.cppreference.com/cpp/container/list/end).

This fixes the issue by decrementing the iterator for these cases so we are pointing at the final element of the log instead of the end() iterator which is one past the end.

Fixes: https://tracker.ceph.com/issues/80359

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@JonBailey1993
JonBailey1993 requested a review from a team as a code owner September 7, 2026 16:10
@github-actions github-actions Bot added the core label Sep 7, 2026
@JonBailey1993
JonBailey1993 force-pushed the fix_undefined_iterator_access branch 2 times, most recently from f45c42b to 43a6d6b Compare September 7, 2026 16:11

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fixed issue was introduced by #64917. which was included by umbrella. shall have a tracker ticket for the issue, so that we can backport the fix to umbrella?

@tchaikov
tchaikov requested a review from bill-scales September 8, 2026 00:47
@JonBailey1993 JonBailey1993 self-assigned this Sep 8, 2026
@JonBailey1993

Copy link
Copy Markdown
Contributor Author

Thanks very much. I have now created a tracker ticket here: https://tracker.ceph.com/issues/80359

@tchaikov

tchaikov commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@JonBailey1993 thanks for create the tracker ticket . could you associate this fix with it? namely, to add a "Fixes: https://tracker.ceph.com/issues/80359" tag in the commit message.

In proc_master_log, we need to decide when to call consider_adjusting_pwlc(...).
We do this by comparing the incoming log from a message against our own log.
We use an iterator pointing at the end of the incoming log and compare it to our
own log in various ways to determine if we need to adjust the pwlc values.
For all non-empty cases, we were comparing olog.log.end()->version with
p->version, where accessing olog.log.end() results in undefined behaviour
(https://en.cppreference.com/cpp/container/list/end).

This fixes the issue by decrementing the iterator for these cases so we are
pointing at the final element of the log instead of the end() iterator which is
one past the end.

Fixes: https://tracker.ceph.com/issues/80359
Signed-off-by: Jon Bailey <[email protected]>
Assisted-by: IBM Bob 2.2.0
@JonBailey1993
JonBailey1993 force-pushed the fix_undefined_iterator_access branch from 43a6d6b to 40d4890 Compare September 9, 2026 08:41
@JonBailey1993

Copy link
Copy Markdown
Contributor Author

@tchaikov I've added a trailer to the commit and modified the PR description so both use the format you describe.

@JonBailey1993

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@JonBailey1993

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath10-testing-20260910.230227-main.

@bill-scales

Copy link
Copy Markdown
Contributor

The fix in this PR is very similar to the fix in #70149. I've also got a commit that extends the peering state test harness to unit test the 3 modified code paths.

@connorfawcett

Copy link
Copy Markdown
Contributor

@bill-scales

Copy link
Copy Markdown
Contributor

As mentioned previously, the changes on this commit are similar to those on #70149. It is somewhat reassuring that two independent bits of debugging have arrived at essentially the same fix, however there is an additional fix included in 70149 that is missing from this PR that correctly handles pwlc when there are gaps in the log (for example caused by a PG split).

I suggest closing this PR as a duplicate of 70149

@JonBailey1993

Copy link
Copy Markdown
Contributor Author

Closing in favour of 70149 so that the extra fix added in that PR will be merged as suggested by @bill-scales

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants