Avoid confusing AIO callback lifetime test#13159
Merged
Merged
Conversation
Coverity reports the AIO callback lifetime regression test as a leak and bad free because the test heap-allocates an owner object whose member callback is destroyed indirectly during completion. The runtime behavior is intentional, but the ownership pattern makes the regression test look invalid to static analysis. This updates the fixture so the owner has normal stack lifetime and owns the callback through a unique_ptr. The completion handler still destroys the callback before AIOCallback::io_complete() returns, preserving the lifetime coverage while making the allocation and free visible to analysis.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors an AIO callback regression test to use stack-allocated owner with a unique_ptr-managed callback, avoiding Coverity false positives about leaks/bad frees while preserving the lifetime test coverage.
Changes:
- Replace heap-allocated
AIOCompletionOwnerwith stack allocation - Wrap
AIOCallbackmember instd::unique_ptrso it can be destroyed during completion - Update test name and assertions to reflect the new ownership model
zwoop
reviewed
May 13, 2026
| auto *callback = owner.callback.get(); | ||
|
|
||
| // Without ASan, a broken implementation can still pass because the stale value of from_ts_api is typically false. | ||
| CHECK(callback->io_complete(EVENT_NONE, nullptr) == EVENT_DONE); |
Contributor
There was a problem hiding this comment.
Not important, but after completing this, I think callback is in an undefined state. We don't use it after this, but maybe we should NULL it out or something ? In case someone looks at this after we retire.
zwoop
approved these changes
May 13, 2026
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.
Coverity reports the AIO callback lifetime regression test as a leak
and bad free because the test heap-allocates an owner object whose
member callback is destroyed indirectly during completion. The runtime
behavior is intentional, but the ownership pattern makes the regression
test look invalid to static analysis.
This updates the fixture so the owner has normal stack lifetime and
owns the callback through a unique_ptr. The completion handler still
destroys the callback before AIOCallback::io_complete() returns,
preserving the lifetime coverage while making the allocation and free
visible to analysis.