Repository navigation
Conversation
|
Hi @chennaji9. Thanks for your PR. I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
create() is noexcept but its vector allocation can throw length_error/bad_alloc, terminating the process; reject capacities above vector::max_size() up front and convert remaining allocation errors into the empty optional the API already uses for failure; add a unit test. Signed-off-by: 陈那几 <2078634206@qq.com>
b217596 to
303a877
Compare
|
@reddevillg 您好,打扰一下~CI 这边仍在等 org 成员的 /ok-to-test 放行(commitlint 问题 10-15 已修复跟进)。方便的话能否帮忙触发一下 CI?绿了之后也恳请帮忙 review、合入,辛苦了,感谢! |
What does this PR do?
RingBuffer::create()is declarednoexcept, but it allocates its backing storage withstd::vector<std::byte> data(cap), which can throw:std::length_errorwhencap > vector::max_size(),std::bad_allocon out-of-memory.An exception escaping a
noexceptfunction callsstd::terminate()— the process dies instead of reporting failure through the emptystd::optionalthe API already defines for that purpose (e.g.cap == 0today).Fix:
std::vector<std::byte>().max_size()up front (deterministic, no exception), andtry/catch (...)returningstd::nullopt, keeping thenoexceptinterface honest.Validation
RingBuffer.CreateRejectsOversizedCapacityrequests1 << (sizeof(std::size_t) * CHAR_BIT - 1)(a power of two abovemax_size()); it asserts the empty optional is returned. Verified againstroundUpPowerOf2that this input reaches the guard without wrapping to 0.ctest -R RingBuffer→ 7/7 Passed (CreateRejectsZeroCapacity,RoundsUpToPowerOfTwo,EmptyAndFullStates,WriteAndReadViaIovecs,WrapsAround,ClearResetsState,CreateRejectsOversizedCapacity).ll-teststarget builds cleanly with the change.