When GCC is configured with --enable-libstdcxx-allocator=pool we get this test failure: FAIL: 27_io/manipulators/standard/wchar_t/2.cc (test for excess errors) Excess errors: /usr/bin/ld: Dwarf Error: Can't find .debug_ranges section. 2.cc:(.text._ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEED2Ev[_ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEED5Ev]+0x44): undefined reference to `__gnu_cxx::__pool_alloc<wchar_t>::deallocate(wchar_t*, unsigned long)' 2.cc:(.text._ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEED0Ev[_ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEED5Ev]+0x44): undefined reference to `__gnu_cxx::__pool_alloc<wchar_t>::deallocate(wchar_t*, unsigned long)' 2.cc:(.text._Z6test01v+0x464): undefined reference to `__gnu_cxx::__pool_alloc<wchar_t>::deallocate(wchar_t*, unsigned long)' 2.cc:(.text._Z6test01v+0x4c4): undefined reference to `__gnu_cxx::__pool_alloc<wchar_t>::deallocate(wchar_t*, unsigned long)' 2.cc:(.text._Z6test01v+0x51c): undefined reference to `__gnu_cxx::__pool_alloc<wchar_t>::deallocate(wchar_t*, unsigned long)' collect2: error: ld returned 1 exit status The specialization is explicitly instantiated in src/c++98/pool_allocator.cc: // Instantiations. template class __pool_alloc<char>; template class __pool_alloc<wchar_t>; But the symbols have never been exported, so dynamic link fails (static linking works though). Similarly, when built with --enable-libstdcxx-allocator=mt lots of tests fail, because the __gnu_cxx::__common_pool<__gnu_cxx::__pool, true>::_S_get_pool()::_S_pool static variable and its guard variable are not exported. That means the linker cannot combine the definition in libstdc++.so with the one in user code, and we get two copies of it. This means allocations and deallocations might happen in different pools, and so segfault. And --enable-libstdcxx-allocator=bitmap is completely broken, see PR 103381. it's not clear whether it's worth salvaging these extensions, or if we should just deprecate and them remove them.
(In reply to Jonathan Wakely from comment #0) > Similarly, when built with --enable-libstdcxx-allocator=mt lots of tests > fail, because the __gnu_cxx::__common_pool<__gnu_cxx::__pool, > true>::_S_get_pool()::_S_pool static variable and its guard variable are not > exported. That means the linker cannot combine the definition in > libstdc++.so with the one in user code, and we get two copies of it. This > means allocations and deallocations might happen in different pools, and so > segfault. nm /tmp/alloc/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so | fgrep _S_pool 00000000002205e8 b _ZGVZN9__gnu_cxx13__common_poolINS_6__poolELb1EE11_S_get_poolEvE7_S_pool 0000000000220600 b _ZZN9__gnu_cxx13__common_poolINS_6__poolELb1EE11_S_get_poolEvE7_S_pool They should have type 'u'. It can be fixed by: --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -2400,6 +2400,8 @@ GLIBCXX_3.4.29 { GLIBCXX_3.4.30 { _ZSt21__glibcxx_assert_fail*; + _ZGVZN9__gnu_cxx13__common_poolINS_6__poolELb1EE11_S_get_poolEvE7_S_pool; + _ZZN9__gnu_cxx13__common_poolINS_6__poolELb1EE11_S_get_poolEvE7_S_pool; } GLIBCXX_3.4.29;
(In reply to Jonathan Wakely from comment #0) > And --enable-libstdcxx-allocator=bitmap is completely broken, see PR 103381. Repeating PR 103381 comment 4: Every test fails with: /usr/bin/ld: .../libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `__gnu_cxx::bitmap_allocator<unsigned int>::_S_last_request' /usr/bin/ld: .../libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `__gnu_cxx::bitmap_allocator<std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<std::mutex>, (__gnu_cxx::_Lock_policy)2> >::_S_mut' /usr/bin/ld: .../libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `__gnu_cxx::bitmap_allocator<std::_Sp_counted_ptr_inplace<std::__future_base::_State_baseV2, std::allocator<std::__future_base::_State_baseV2>, (__gnu_cxx::_Lock_policy)2> >::_S_mut' /usr/bin/ld: .../libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `__gnu_cxx::bitmap_allocator<std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<std::mutex>, (__gnu_cxx::_Lock_policy)2> >::_S_mem_blocks' /usr/bin/ld: .../libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `__gnu_cxx::bitmap_allocator<std::_Sp_counted_ptr_inplace<std::__future_base::_State_baseV2, std::allocator<std::__future_base::_State_baseV2>, (__gnu_cxx::_Lock_policy)2> >::_S_last_request' /usr/bin/ld: .../libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `__gnu_cxx::bitmap_allocator<unsigned int>::_S_mut' /usr/bin/ld: .../libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `__gnu_cxx::bitmap_allocator<unsigned int>::_S_mem_blocks' /usr/bin/ld: .../libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `__gnu_cxx::bitmap_allocator<std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<std::mutex>, (__gnu_cxx::_Lock_policy)2> >::_S_last_request' /usr/bin/ld: .../libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `__gnu_cxx::bitmap_allocator<std::_Sp_counted_ptr_inplace<std::__future_base::_State_baseV2, std::allocator<std::__future_base::_State_baseV2>, (__gnu_cxx::_Lock_policy)2> >::_S_mem_blocks'
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:e2e98f524fdb80c16e3395f20fee930fbcad5562 commit r12-5754-ge2e98f524fdb80c16e3395f20fee930fbcad5562 Author: Jonathan Wakely <jwakely@redhat.com> Date: Wed Dec 1 16:30:30 2021 +0000 libstdc++: Remove broken std::allocator base classes [PR103340] The bitmap_allocator, __mt_alloc and __pool_alloc extensions are no longer suitable for use as the base class of std::allocator, because they have not been updated to meet the C++20 requirements. There is a patch attached to PR 103340 which addresses that, but more work would be needed to solve the linking errors that occur when the library is configured to use them. Using --enable-libstdcxx-allocator=bitmap wouldn't even bootstrap for the past few years, and I can't find any gcc-testresults reports using any of these allocators. This patch removes the configure option to use these as the std::allocator base class. The allocators are still in the tree and can be used directly, you just can't configure the library to use one of them as the base class of std::allocator. libstdc++-v3/ChangeLog: PR libstdc++/103340 PR libstdc++/103400 PR libstdc++/103381 * acinclude.m4 (GLIBCXX_ENABLE_ALLOCATOR): Remove mt, bitmap and pool options. * configure: Regenerate. * config/allocator/bitmap_allocator_base.h: Removed. * config/allocator/mt_allocator_base.h: Removed. * config/allocator/pool_allocator_base.h: Removed. * doc/xml/manual/allocator.xml: Update. * doc/xml/manual/configure.xml: Update. * doc/xml/manual/evolution.xml: Document removal. * doc/xml/manual/mt_allocator.xml: Editorial tweaks. * doc/html/manual/*: Regenerate.
Fixed by removing these allocators as possible implementations of std::allocator.