fix: handle zero secure allocator pool count#7346
Conversation
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR makes the Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 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)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Infer (1.2.0)src/test/allocator_tests.cppsrc/test/allocator_tests.cpp:5:10: fatal error: 'support/allocators/mt_pooled_secure.h' file not found ... [truncated 1148 characters] ... nstall/lib/clang/18/include" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ No Merge Conflicts DetectedThis PR currently has no conflicts with other open PRs. |
|
✅ Review complete (commit 427a5af) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
Both agents independently flagged no in-scope issues for this small, focused fix. The change correctly clamps pools_count to a minimum of 1 to prevent modulo-by-zero in get_bucket(), and the added unit test deterministically exercises the zero-pool path via the new explicit constructor parameter.
Note: GitHub does not allow approving the author's own PR, so this clean automated review is posted as a neutral comment.
fix: handle zero secure allocator pool count
Issue being fixed or feature implemented
std::thread::hardware_concurrency()is allowed to return0.mt_pooled_secure_allocatorused that value directly as the secure pool count,which could leave the allocator with no pools and make the first allocation
compute a bucket modulo zero.
This keeps normal behavior unchanged while making the edge case safe.
What was done?
allocation/deallocation still work.
How Has This Been Tested?
Tested on macOS arm64 with the depends config site build environment.
git diff --checkmake -C src -j8 test/test_dashallocator_tests/mt_pooled_secure_allocator_zero_pool_countallocator_testsshipBreaking Changes
None.
Checklist
(for repository code-owners and collaborators only)