Skip to content

Commit c6b214a

Browse files
committed
Loosen map reserve bound in regression test for STL bucket baseline
The unordered_map assertion used a tight <= payload.size() bound, but unordered_map implementations pre-allocate a baseline bucket array (MSVC's STL starts at 16), so CI failed on Windows with "reserve requested 16 buckets for a 5-byte payload". The vector case has no such baseline and is unaffected. Use a generous constant ceiling (1024) for the bucket allocation, which still cleanly separates a bounded reservation from the multi-billion-bucket bug: verified the test still fails (~2^32 buckets requested) when the cap is removed.
1 parent feda27a commit c6b214a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

tests/msgpack_test/msgpack_test.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,12 @@ suite msgpack_reserve_amplification_tests = [] {
514514
const auto ec = glz::read_msgpack(m, map32_bomb);
515515
expect(ec.ec == glz::error_code::unexpected_end)
516516
<< "expected unexpected_end, got: " << glz::format_error(ec, map32_bomb);
517-
// Bucket count scales with the reservation; the cap keeps it within the buffer size.
518-
expect(g_largest_alloc_count <= map32_bomb.size())
517+
// The reservation must stay a small constant tied to the input, not the 2^32-1 wire count.
518+
// Unlike the vector case, unordered_map implementations pre-allocate a baseline bucket array
519+
// (e.g. the MSVC STL starts at 16), so an exact input-size bound does not hold here. A generous
520+
// ceiling still cleanly separates a bounded reservation from the multi-billion-bucket bug.
521+
constexpr size_t sane_bucket_bound = 1024;
522+
expect(g_largest_alloc_count < sane_bucket_bound)
519523
<< "reserve requested " << g_largest_alloc_count << " buckets for a " << map32_bomb.size()
520524
<< "-byte payload";
521525
};

0 commit comments

Comments
 (0)