fix: Proper handling of system shm register offset#8330
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in shared memory handling where the register offset was being applied twice during memory mapping operations, leading to out-of-bounds read issues. The fix ensures that when mmap returns a starting address that already includes the register offset, the offset is not added again during memory access.
Key changes:
- Removes duplicate register offset calculation in the C++ shared memory manager
- Updates test utilities to properly handle register offsets for different memory types
- Adds comprehensive tests for large shared memory register offsets across multiple backend types
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/shared_memory_manager.cc | Removes duplicate register offset calculation for CPU memory types |
| qa/common/infer_util.py | Updates test utility to handle register offsets and support multiple model backends |
| qa/L0_shared_memory/test.sh | Adds test infrastructure for large shared memory register offset testing |
| qa/L0_shared_memory/shared_memory_test.py | Implements comprehensive test for large register offsets across backend types |
yinggeh
commented
Aug 6, 2025
| *shm_info = std::static_pointer_cast<const SharedMemoryInfo>(it->second); | ||
| } | ||
|
|
||
| if (it->second->kind_ == TRITONSERVER_MEMORY_CPU) { |
Contributor
Author
There was a problem hiding this comment.
System shm is treated differently from CUDA shm. mmap returns the address starting at the offset. Therefore no need to add another offset to it.
tanmayv25
approved these changes
Aug 6, 2025
yinggeh
added a commit
that referenced
this pull request
Aug 7, 2025
mc-nv
pushed a commit
that referenced
this pull request
Aug 7, 2025
mc-nv
added a commit
that referenced
this pull request
Aug 14, 2025
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.
What does the PR do?
When calling
mmapsystem call, the returned starting address is starting at the shm register offset (must be multiples of page size) already. Later the register offset is added to the starting address again and raises out-of-bound write issue.Checklist
<commit_type>: <Title>Commit Type:
Check the conventional commit type
box here and add the label to the github PR.
Related PRs:
Where should the reviewer start?
Test plan:
L0_shared_memory
L0_cuda_shared_memory
32791300
Caveats:
Background
https://man7.org/linux/man-pages/man2/mmap.2.html
Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)