Repository navigation
Conversation
99fee1f to
468542d
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The regression test does not cover the independently changed server-handshake path for overlong peer names, leaving its collision-prone fallback behavior unverified.
1 open issue
What changed in this PR
This PR hardens UB shared-memory setup by rejecting names that would be truncated by snprintf, preventing collisions or unintended shared-memory object usage, and releases the client transaction slot when local-name construction fails.
Changes:
- Detect truncation when constructing client, server, and remote shared-memory names.
- Fall back from UB when generated names cannot be represented safely.
- Add regression coverage for transaction-slot reuse after rejected setup.
| File | Description |
|---|---|
| test/brpc_ubring_unittest.cpp | Adds regression coverage verifying that a rejected overlong local shared-memory name releases the transaction slot for reuse. |
| src/brpc/ubshm/ub_ring.cpp | Rejects truncated client and remote shared-memory names and releases the client transaction when local-name construction fails. |
| src/brpc/ubshm/ub_endpoint.cpp | Rejects truncated server shared-memory names during handshake and falls back from UB. |
Review effort: Lite
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
1 resolved since last review
Review effort: Lite


What problem does this PR solve?
Issue Number: resolve
Problem Summary:
UB shared-memory names are generated with
snprintf, but the previous codeonly handled negative return values. An overlong endpoint name could therefore
silently truncate the generated shared-memory name, causing collisions or use
of an unintended shared-memory object.
What is changed and the side effects?
Changed:
snprintftruncation as an error when generating client and servershared-memory names.
fails.
verifies the slot can be acquired again after the rejected setup.
Side effects:
Performance effects:
None on successful setup paths.
Breaking backward compatibility:
Connections whose generated shared-memory names exceed the fixed limit now
fall back instead of silently using a truncated name.
Check List: