Skip to content

[Integration] Reject failed Python buddy allocator backing buffer#2402

Merged
alogfans merged 1 commit into
kvcache-ai:mainfrom
he-yufeng:fix/python-buddy-null-allocation
Jun 10, 2026
Merged

[Integration] Reject failed Python buddy allocator backing buffer#2402
alogfans merged 1 commit into
kvcache-ai:mainfrom
he-yufeng:fix/python-buddy-null-allocation

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

  • stop buddy allocation when the backing raw buffer allocation or registration fails
  • leave buffer_list_ and the slab free lists unchanged on failure
  • propagate the failure to allocateManagedBuffer, which already returns a null address

Problem

The max-class branch appended the result of allocateRawBuffer without checking it. On allocation failure or local-memory registration failure, this inserted nullptr into buffer_list_ and derived invalid addresses into free_list_, while reporting success.

Fixes #2371.

Validation

  • git diff --check
  • source-path review against current upstream/main

To verify

  • Mooncake integration C++ build and CI on Linux
  • failure-injection coverage for raw backing-buffer allocation, where available

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds a null check after allocating a raw buffer in TransferEnginePy::doBuddyAllocate to prevent pushing a null pointer to the buffer list and avoid potential crashes. There are no review comments to address, and the change looks correct.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...integration/transfer_engine/transfer_engine_py.cpp 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jfeng18 jfeng18 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. Clean minimal fix — checks allocateRawBuffer return before mutating buffer_list_ and free_list_. This prevents the NameError-equivalent in C++ where nullptr seeds the buddy allocator with invalid addresses.

One observation: when allocateRawBuffer fails, the class_id split loop in allocateManagedBuffer will retry doBuddyAllocate at progressively larger class_ids until kMaxClassId, then return nullptr to the caller. This is the correct failure propagation — no further changes needed.

@alogfans alogfans left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alogfans alogfans merged commit 8dbb0e1 into kvcache-ai:main Jun 10, 2026
17 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Py] doBuddyAllocate does not check nullptr from allocateRawBuffer

4 participants