Coverity: delete leaf RegressionSM instances when they complete - #13690
Merged
bryancall merged 1 commit intoSep 17, 2026
Merged
Conversation
ReRegressionSM::run() completes synchronously and never reaches regression_sm_waiting(), so nothing ever freed the six instances the test builds or the six clones RegressionSM::run() makes for the repeat counts. Composite nodes already delete themselves; leaves now follow the same contract CacheTestSM::complete() uses. Coverity CID 1022149, CID 1022150, CID 1022151.
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The lifetime change is compile-verified but not exercised by a ctest case and requires human validation.
Pull request overview
Fixes leaks from synchronous leaf RegressionSM instances by deleting them after completion.
Changes:
- Adds self-deletion to
ReRegressionSM::run(). - Preserves existing composite cleanup behavior.
File summaries
| File | Description |
|---|---|
src/iocore/cache/RegressionSM.cc |
Deletes completed leaf state machines. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Author
|
@JosiahWI It is a test and a one liner. |
JosiahWI
approved these changes
Sep 17, 2026
JosiahWI
left a comment
Contributor
There was a problem hiding this comment.
Change is an improvement.
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.
One commit, three CIDs, one file. Separated from the rest of #13682 because it is the only change in that series that alters object lifetime in the cache regression machinery, and the only one no ctest case can exercise.
What leaks
REGRESSION_TEST(RegressionSM)builds a tree ofRegressionSMnodes and callstop_sm->run(pstatus). Nothing is ever deleted, which is what CIDs 1022149, 1022150 and 1022151 report.The ownership split matters:
RegressionSM::run()whennwaitinghits 0 after the child loop, andregression_sm_waiting()whennwaitingis 0 on the retry callback. Every other path either reschedules or re-entersrun().ReRegressionSM::run()callsdone()synchronously and returns, so it never schedules and therefore never reachesregression_sm_waiting()— which is the only place that would have deleted it.So 12 leaf instances leak per run: the 6 built by the test body, plus 6 more created internally by
RegressionSM::run()'s repeat path (children[0]->clone()forichild != n-1).Deleting the tree from the test body would be a double-free. This is worth stating explicitly because it is the obvious-looking fix: a
unique_ptrvector in the test body (attempted in0690f09282, never merged) also cannot reach the internally-created clones.Why self-delete is safe here
xrun()touches no members afterrun()returns;done()touches none afterparent->child_done()returns; the child loop never re-reads the node afterxrun(); and in the repeat pathchildren[0]is only dereferenced for cloning on iterations0..n-2and handed over on the last, so it dies last. A parent always outlives its children, since itsnwaitingonly reaches 0 after every child'schild_done().This is the same contract
CacheTestSM::complete()already uses in this subsystem (done(); delete this;), so the change makes the two leaf implementations consistent rather than introducing a new rule.Verification status — please read before merging
RegressionSMis aREGRESSION_TESTcompiled intoinkcacheand invoked viatraffic_server -R. No ctest case exercises it, so this change is compile-verified and reasoned about but has not been executed. It wants an-Rrun.For completeness: CIDs 1021840 and 1021841 (
RegressionTest_cache, also resource leaks) are not addressed here, because nothing in that function leaks. The 12CACHE_SMprototypes are stack objects that are only cloned, never run; the clones are leaves that self-delete viacomplete(); the composites self-delete as above. Those two are recommended for triage as false positives in #13682.