public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/103400] New: src/c++98/*_allocator.cc symbols not exported
@ 2021-11-23 23:36 redi at gcc dot gnu.org
  2021-11-23 23:41 ` [Bug libstdc++/103400] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-11-23 23:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103400

            Bug ID: 103400
           Summary: src/c++98/*_allocator.cc symbols not exported
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: link-failure
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/103400] src/c++98/*_allocator.cc symbols not exported
  2021-11-23 23:36 [Bug libstdc++/103400] New: src/c++98/*_allocator.cc symbols not exported redi at gcc dot gnu.org
@ 2021-11-23 23:41 ` redi at gcc dot gnu.org
  2021-11-24  0:03 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-11-23 23:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103400

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(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;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/103400] src/c++98/*_allocator.cc symbols not exported
  2021-11-23 23:36 [Bug libstdc++/103400] New: src/c++98/*_allocator.cc symbols not exported redi at gcc dot gnu.org
  2021-11-23 23:41 ` [Bug libstdc++/103400] " redi at gcc dot gnu.org
@ 2021-11-24  0:03 ` redi at gcc dot gnu.org
  2021-12-02 16:53 ` cvs-commit at gcc dot gnu.org
  2021-12-02 17:18 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-11-24  0:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103400

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(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'

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/103400] src/c++98/*_allocator.cc symbols not exported
  2021-11-23 23:36 [Bug libstdc++/103400] New: src/c++98/*_allocator.cc symbols not exported redi at gcc dot gnu.org
  2021-11-23 23:41 ` [Bug libstdc++/103400] " redi at gcc dot gnu.org
  2021-11-24  0:03 ` redi at gcc dot gnu.org
@ 2021-12-02 16:53 ` cvs-commit at gcc dot gnu.org
  2021-12-02 17:18 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-02 16:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103400

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/103400] src/c++98/*_allocator.cc symbols not exported
  2021-11-23 23:36 [Bug libstdc++/103400] New: src/c++98/*_allocator.cc symbols not exported redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-12-02 16:53 ` cvs-commit at gcc dot gnu.org
@ 2021-12-02 17:18 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-02 17:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103400

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed by removing these allocators as possible implementations of
std::allocator.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-02 17:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 23:36 [Bug libstdc++/103400] New: src/c++98/*_allocator.cc symbols not exported redi at gcc dot gnu.org
2021-11-23 23:41 ` [Bug libstdc++/103400] " redi at gcc dot gnu.org
2021-11-24  0:03 ` redi at gcc dot gnu.org
2021-12-02 16:53 ` cvs-commit at gcc dot gnu.org
2021-12-02 17:18 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).