Skip to content

osd: free the stack of an EC coroutine op and keep its sync reads in it - #73193

Merged
MattyWilliams22 merged 1 commit into
ceph:mainfrom
MattyWilliams22:wip-free-coro-stack
Nov 13, 2026
Merged

MattyWilliams22 merged 1 commit into
ceph:mainfrom
MattyWilliams22:wip-free-coro-stack

Conversation

@MattyWilliams22

Copy link
Copy Markdown
Contributor

An op that ended without a yield dropped the last reference to its coroutine inside the coroutine, so its 128 KiB stack leaked. Now resume_coroutine() holds a reference across the resume. The op also kept handles into the freed stack, and a later sync read yielded on them. Now the coroutine clears them and waits for the op's async reads itself, also when an op before the CALL started them before any sync read.

Fixes: https://tracker.ceph.com/issues/81777
Assisted-by: Claude:claude-opus-5-5

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.

@MattyWilliams22

Copy link
Copy Markdown
Contributor Author

I have tested in Teuthology with and without this fix and have seen promising results:
Main branch: https://pulpito-ng.ceph.com/runs/mattywilliams-2026-10-27_14:56:30-rados:verify-main-distro-default-trial
This branch: https://pulpito-ng.ceph.com/runs/mattywilliams-2026-10-27_14:55:01-rados:verify-main-distro-default-trial

The jobs on the main branch all show Leak_DefinitelyLost for the boost coroutine that is spawned in PrimaryLogPG::do_op(). The jobs on this branch show no signs of these memory leaks.

@MattyWilliams22
MattyWilliams22 marked this pull request as ready for review October 28, 2026 11:12
@MattyWilliams22
MattyWilliams22 requested a review from a team as a code owner October 28, 2026 11:12

@aainscow aainscow 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

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath15-testing-20261102.042818-main.

@ronen-fr

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

An op that ended without a yield dropped the last reference to its
coroutine inside the coroutine, so its 128 KiB stack leaked. Now
resume_coroutine() holds a reference across the resume. The op also kept
handles into the freed stack, and a later sync read yielded on them. Now
the coroutine clears them and waits for the op's async reads itself,
also when an op before the CALL started them before any sync read.

Rebasing this commit required the resolution of a merge conflict.
The merge conflict was in the definitions of do_op_impl() and do_op() in src/osd/PrimaryLogPG.h which both now have an extra parameter.
The resolution was to keep the extra parameters from main.

Fixes: https://tracker.ceph.com/issues/81777
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
Signed-off-by: Matty Williams <[email protected]>
@MattyWilliams22

Copy link
Copy Markdown
Contributor Author

This force push was a rebase. There was a minor conflict which I've described in the commit message. I don't believe that QA needs to be redone.

@MattyWilliams22

Copy link
Copy Markdown
Contributor Author

jenkins test api

@MattyWilliams22

Copy link
Copy Markdown
Contributor Author

jenkins test windows

1 similar comment
@MattyWilliams22

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@MattyWilliams22
MattyWilliams22 merged commit 780624c into ceph:main Nov 13, 2026
14 checks passed
@MattyWilliams22
MattyWilliams22 deleted the wip-free-coro-stack branch November 13, 2026 13:31
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.

5 participants