I implicitly assumed that programs using pmr::synchronized_pool_resource would also be using multiple threads, and so the weak symbols in gthr-posix.h would be resolved by linking to libpthread. If that isn't true then it crashes when trying to use pthread_key_create. This commit makes the pool resource check __gthread_active_p() before using thread-specific data, and just use a single set of memory pools when there's only a single thread. PR libstdc++/94936 * src/c++17/memory_resource.cc (synchronized_pool_resource::_TPools): Add comment about single-threaded behaviour. (synchronized_pool_resource::_TPools::move_nonempty_chunks()): Hoist class member access out of loop. (synchronized_pool_resource::synchronized_pool_resource()) (synchronized_pool_resource::~synchronized_pool_resource()) (synchronized_pool_resource::release()): Check __gthread_active_p before creating and/or deleting the thread-specific data key. (synchronized_pool_resource::_M_thread_specific_pools()): Adjust assertions. (synchronized_pool_resource::do_allocate(size_t, size_t)): Add fast path for single-threaded case. (synchronized_pool_resource::do_deallocate(void*, size_t, size_t)): Likewise. Return if unable to find a pool that owns the allocation. * testsuite/20_util/synchronized_pool_resource/allocate_single.cc: New test. * testsuite/20_util/synchronized_pool_resource/cons_single.cc: New test. * testsuite/20_util/synchronized_pool_resource/release_single.cc: New test. (cherry picked from commit ec40967f1323069da3a5a45286f71fa4f80926df)
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
Makefile.am | Loading commit data... | |
Makefile.in | Loading commit data... | |
cow-fs_dir.cc | Loading commit data... | |
cow-fs_ops.cc | Loading commit data... | |
cow-fs_path.cc | Loading commit data... | |
cow-string-inst.cc | Loading commit data... | |
default_resource.h | Loading commit data... | |
fs_dir.cc | Loading commit data... | |
fs_ops.cc | Loading commit data... | |
fs_path.cc | Loading commit data... | |
memory_resource.cc | Loading commit data... | |
ostream-inst.cc | Loading commit data... | |
string-inst.cc | Loading commit data... |