mooncake: fix request array leak on postXfer error path#1828
mooncake: fix request array leak on postXfer error path#1828EylonKrause wants to merge 1 commit into
Conversation
|
👋 Hi EylonKrause! Thank you for contributing to ai-dynamo/nixl. Your PR reviewers will review your contribution then trigger the CI to test your changes. 🚀 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesTransfer request buffer refactor in mooncake_backend
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/plugins/mooncake/mooncake_backend.cpp`:
- Line 288: The submitTransferWithNotify call in mooncake_backend.cpp exceeds
the style line-length limit and should be wrapped to keep lines at or under 100
characters. Reformat the call at the submitTransferWithNotify site in
mooncake_backend.cpp so the arguments are split across multiple lines,
preferably one argument per line, while preserving the existing rc assignment
and behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: d77f288b-0585-49ee-a9f1-464a2a4e4c11
📒 Files selected for processing (1)
src/plugins/mooncake/mooncake_backend.cpp
nixlMooncakeEngine::postXfer allocated the transfer_request_t array with new[] and only delete[]'d it after the submit loop. The per-descriptor length check inside that loop returns NIXL_ERR_INVALID_PARAM before the delete[], leaking the whole array on every length-mismatched request (descCount() equality is pre-checked, but per-descriptor len is not, so that early return is reachable from caller input). Use std::vector<transfer_request_t> so the array is freed on every exit path, and pass request.data() to submitTransfer/submitTransferWithNotify. Signed-off-by: Eylon Krause <eylon1909@gmail.com>
626a569 to
3f0b91d
Compare
What?
nixlMooncakeEngine::postXfer(src/plugins/mooncake/mooncake_backend.cpp) allocatedthe
transfer_request_tarray withnew[]and onlydelete[]'d it once, after thesubmit loop:
It now uses
std::vectorand passesrequest.data()tosubmitTransfer/submitTransferWithNotify.Why?
The per-descriptor length check inside the fill loop returns
NIXL_ERR_INVALID_PARAMbefore the lonedelete[], leaking the whole array onevery length-mismatched request. The
descCount()equality is pre-checked, but theper-descriptor
lenis not — so that early return is reachable from caller input.std::vectorfrees on every exit path and removes the manualdelete[].Reproduction
The Mooncake plugin requires the Mooncake Transfer Engine library, which isn't present
in my environment, so I verified the leak with an extracted reproducer of the
new[]/ loop-with-early-return /delete[]shape (2 descriptors, the second with alength mismatch), built with
-fsanitize=address,leak:std::vectoris already used elsewhere in this file, so the change needs no new include.Related Issues
None.
Summary by CodeRabbit