Fix overflows in std::pmr::unsynchonized_pool_resource
commitca476f5993622d3421142680ac9ff9bab9410126
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Nov 2018 22:57:44 +0000 (13 22:57 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Nov 2018 22:57:44 +0000 (13 22:57 +0000)
tree0e71c13741900a8eab433e8a507bbfe08fc89621
parentdd59ba4341375df89e81e9752cf6b0748c2702c0
Fix overflows in std::pmr::unsynchonized_pool_resource

* src/c++17/memory_resource.cc (bitset::full()): Handle edge case
for _M_next_word maximum value.
(bitset::get_first_unset(), bitset::set(size_type)): Use
update_next_word() to update _M_next_word.
(bitset::update_next_word()): New function, avoiding wraparound of
unsigned _M_next_word member.
(bitset::max_word_index()): New function.
(chunk::chunk(void*, uint32_t, void*, size_t)): Add assertion.
(chunk::max_bytes_per_chunk()): New function.
(pool::replenish(memory_resource*, const pool_options&)): Prevent
_M_blocks_per_chunk from exceeding max_blocks_per_chunk or from
causing chunk::max_bytes_per_chunk() to be exceeded.
* testsuite/20_util/unsynchronized_pool_resource/allocate-max-chunks.cc:
New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266087 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/src/c++17/memory_resource.cc
libstdc++-v3/testsuite/20_util/unsynchronized_pool_resource/allocate-max-chunks.cc [new file with mode: 0644]