Repository navigation
Conversation
PrimaryLogPG::do_op() runs an EC CALL op in a coroutine owned by coro_resumer, and the coroutine body ends with on_coroutine_complete(), which resets coro_resumer. CoroHandles only keeps a weak_ptr, so when the op completes without yielding, that reset drops the last reference and destroys the push_type while the coroutine is still running on its own stack. The fiber is then never unwound and its 128KB stack leaks, once per such op. rados/verify valgrind jobs report it as Leak_DefinitelyLost in create_control_block, hidden behind the monitor leak that teuthology reports first. A coroutine that yields is resumed by the objects_read_sync() completion, which holds a locked reference, so only the synchronous path leaks. Start the coroutine with start_coroutine(), which holds a local reference while it runs, so a completed coroutine is destroyed after it returns. Fixes: https://tracker.ceph.com/issues/81777 Assisted-by: Claude Code
Count the stacks a coroutine started with start_coroutine() allocates, and check that each is freed when the coroutine completes without yielding, completes after a yield, or is destroyed while suspended. Without the previous commit, CompleteWithoutYieldFreesStack fails and valgrind reports the 128KB stack as definitely lost. Refs: https://tracker.ceph.com/issues/81777 Assisted-by: Claude Code
4 of 14 tasks
Contributor
Author
|
jenkins test make check |
Contributor
|
I think I recall @MattyWilliams22 has been recently poking with this code. |
Contributor
Author
|
@MattyWilliams22 I believe you have been look into this. Please put a quick update of your findings. |
Contributor
|
I have looked into this code and attempted to test it in QA, but I haven't been able to produce any conclusive proof that this code eliminates any memory leaks. I have made another branch (https://github.com/MattyWilliams22/ceph/tree/wip-free-coro-stack) which contains a commit that I think has more promise at solving this problem. I am in the process of testing it now. |
This was referenced Oct 27, 2026
Contributor
|
I have created another PR for this issue, which seems to work more effectively: #73193 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
This PR was generated with AI assistance (Claude Code) to aid the productivity of the PR owner. It has not been reviewed by a human yet, which is why the commits have no Signed-off-by. The fix has been shown to work as follows (more under Testing below):
unittest_osd_coroutines:CompleteWithoutYieldFreesStackfails whenstart_coroutine()keeps no reference (as on main), and valgrind then reports the 128 KB stack definitely lost increate_control_block, the same stack as the teuthology jobs. With the fix it passes with no valgrind errors.rados/verifyvalgrindrados_api_testsjobs that showed this leak on every OSD (https://pulpito-ng.ceph.com/aainscow-2026-10-14_13:56:33-rados:verify-wip-aainscow-rados-qa-fixes-261014-distro-default-trial/) were re-run with the same seed and the fix. No OSD or monitor log of either job has a valgrind error: https://pulpito-ng.ceph.com/aainscow-2026-10-14_19:18:46-rados:verify-wip-aainscow-rados-qa-fixes-v3-261014-distro-default-trial/. One job passed; the other failed only on an unrelated test race (test/librados: retry fresh instances in PoolIsInSelfmanagedSnapsMode #72744).PrimaryLogPG::do_op()runs a CALL op on a pool with EC optimizations in a coroutine.coro_resumerowns the coroutine, and the coroutine body ends withon_coroutine_complete(), which resetscoro_resumer. Since #71327,CoroHandleskeeps only aweak_ptr, socoro_resumeris the only strong reference. When the op completes without yielding, the reset destroys the coroutine while it is still running on its own stack. Boost then never unwinds the fiber, and its 128KB stack leaks once per such op. (https://tracker.ceph.com/issues/81777)A coroutine that yields is safe: the
objects_read_sync()completion resumes it through a lockedweak_ptr, which keeps it alive until it returns.rados/verifyvalgrind jobs show the leak asLeak_DefinitelyLost/Leak_PossiblyLostincreate_control_block<...push_coroutine...>from thedo_oplambda. Teuthology reports only the first valgrind error, and on main that is usually the monitorCRYPTO_mallocleak (https://tracker.ceph.com/issues/79831), so this one has been hidden. For example, jobs 629993 and 604377 have it on every OSD. With the monitor leak suppressed, it is the remaining failure.This PR moves the coroutine start into
start_coroutine()inosd/Coroutines.h. It holds a local reference while the coroutine runs, so a completed coroutine is destroyed after it returns, outside its own stack.The in-body reset was introduced by 52f862c (#67079). #71327 (https://tracker.ceph.com/issues/79515) fixed the use-after-free in
on_change()but kept this reset.Testing:
unittest_osd_coroutinescounts the stacks a coroutine started bystart_coroutine()allocates, and checks they are freed when it completes without yielding, completes after a yield, or is destroyed while suspended. Without the fix,CompleteWithoutYieldFreesStackfails, and valgrind reports131,072 bytes in 1 blocks are definitely lostincreate_control_block, the same stack as the teuthology jobs. With the fix, the test passes and valgrind reports no errors.rados/verifyvalidater/valgrindtasks/rados_api_tests, the same two jobs (same seed) that reported this leak in https://pulpito-ng.ceph.com/aainscow-2026-10-14_13:56:33-rados:verify-wip-aainscow-rados-qa-fixes-261014-distro-default-trial/, re-run with this fix: no valgrind errors in any OSD or monitor log of either job (https://pulpito-ng.ceph.com/aainscow-2026-10-14_19:18:46-rados:verify-wip-aainscow-rados-qa-fixes-v3-261014-distro-default-trial/). One job passed; the other failed only onLibRadosPoolIsInSelfmanagedSnapsMode.FreshInstance(https://tracker.ceph.com/issues/64056), where a fresh client read the osdmap from a monitor one epoch behind the pool deletion.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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.
🤖 Generated with Claude Code