[Bug libstdc++/94160] std::pmr::pool_options::max_blocks_per_chunk=1 causes pool resources to return null pointers
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Sep 21 20:18:07 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94160
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:9ae110d4f8edd61cf56ee5fea62cadc8e781e8dc
commit r10-8780-g9ae110d4f8edd61cf56ee5fea62cadc8e781e8dc
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Sep 10 15:39:15 2020 +0100
libstdc++: handle small max_blocks_per_chunk in pool resources [PR 94160]
When a pool resource is constructed with max_blocks_per_chunk=1 it ends
up creating a pool with blocks_per_chunk=0 which means it never
allocates anything. Instead it returns null pointers, which should be
impossible.
To avoid this problem, round the max_blocks_per_chunk value to a
multiple of four, so it's never smaller than four.
libstdc++-v3/ChangeLog:
PR libstdc++/94160
* src/c++17/memory_resource.cc (munge_options): Round
max_blocks_per_chunk to a multiple of four.
(__pool_resource::_M_alloc_pools()): Simplify slightly.
* testsuite/20_util/unsynchronized_pool_resource/allocate.cc:
Check that valid pointers are returned when small values are
used for max_blocks_per_chunk.
(cherry picked from commit 30b41cfbb2dade63e52465234a725d1d02fe70aa)
More information about the Gcc-bugs
mailing list