public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "poulhies at adacore dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/65343] unexpected exception thrown during destruction of static object in debug mode Date: Tue, 25 Jan 2022 14:52:10 +0000 [thread overview] Message-ID: <bug-65343-4-5O02iBmXNp@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-65343-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65343 Marc Poulhiès <poulhies at adacore dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |poulhies at adacore dot com --- Comment #3 from Marc Poulhiès <poulhies at adacore dot com> --- Hi ! It looks like we are seeing this issue using vxworks7 on gcc-11. The test "/testsuite/21_strings/basic_string/requirements/citerators.cc" has been updated since gcc-10 to use __gnu_debug::string: 8<----8<-----8<-----8<-----8<-----8<------ commit 50bb46e4d2543f2a78f97feddcde27e42639dae1 Author: François Dumont <fdumont@gcc.gnu.org> Date: Fri Mar 5 18:50:22 2021 +0100 libstdc++: Fix and complete __gnu_debug::basic_string implementation 8<----8<-----8<-----8<-----8<-----8<------ Currently, the mutexes are created when __gnu_internal::get_mutex() is first called, during the construction of " __gnu_test::citerator<__gnu_debug::string> dtest1;" in main(). #0 __gnu_cxx::__mutex::__mutex (this=0x801a80c0 <__gnu_internal::get_mutex(unsigned char)::m>) at ...libstdc++-v3/include/ext/concurrence.h:132 #1 0x0000000080043188 in __gnu_internal::M::M (this=0x801a80c0 <__gnu_internal::get_mutex(unsigned char)::m>) at .../libstdc++-v3/src/c++11/shared_ptr.cc:38 #2 0x0000000080043268 in __gnu_internal::get_mutex (i=5 '\005') at .../libstdc++-v3/src/c++11/shared_ptr.cc:39 ... #14 0x00000000800005b8 in main () at .../libstdc++-v3/testsuite/21_strings/basic_string/requirements/citerators.cc:29 On vxworks, __GTHREAD_MUTEX_INIT is not defined, so a destructor is defined for the __mutex object (include/ext/concurrence.h:136) and registered with __cxa_atexit. #0 __cxa_atexit (fn=0x800431ac <__tcf_0(void*)>, data=0x0, dso_handle=0x801a5d40) at cxa_atexit.c:215 #1 0x0000000080043290 in __gnu_internal::get_mutex (i=5 '\005') at .../libstdc++-v3/src/c++11/shared_ptr.cc:39 #2 0x0000000080010710 in (anonymous namespace)::get_safe_base_mutex (address=0x801a7f28 <__gnu_test::citerator<__gnu_debug::basic_string<char, std::char_traits<char>, std::allocator<char> > >::_S_container>) at .../libstdc++-v3/src/c++11/debug.cc:66 Then, when main() returns, these mutexes' destructors are called, which on vxworks call semDestroy() that invalidate the mutexes. #0 __gnu_internal::M::~M (this=0x801a8480 <__gnu_internal::get_mutex(unsigned char)::m+960>, __in_chrg=<optimized out>) at .../libstdc++-v3/src/c++11/shared_ptr.cc:38 #1 0x00000000800431e0 in __tcf_0 () at .../libstdc++-v3/src/c++11/shared_ptr.cc:39 #2 0x00000000800f4ae4 in __cxa_finalize (dso_handle=0x0) at cxa_atexit.c:222 #3 0x00000000800f4cac in __do_atexit_work () at cxa_atexit.c:229 #4 0x00000000800ff274 in exit (status=0) at vxexit.c:49 #5 0x00000000800001d8 in _start () A later destructor for the _S_container object then tries to lock the destroyed and now invalid mutexes, leading to an error. #0 __gnu_cxx::__mutex::lock (this=0x801a8200 <__gnu_internal::get_mutex(unsigned char)::m+320>) at .../libstdc++-v3/include/ext/concurrence.h:149 #1 0x0000000080000b1c in __gnu_cxx::__scoped_lock::__scoped_lock (this=0x600e68, __name=...) at ...p/libstdc++-v3/include/ext/concurrence.h:241 #2 0x00000000800109c4 in __gnu_debug::_Safe_sequence_base::_M_detach_all (this=0x801a7f28 <__gnu_test::citerator<__gnu_debug::basic_string<char, std::char_traits<char>, std::allocator<char> > >::_S_container>) at .../libstdc++-v3/src/c++11/debug.cc:255 ... #7 0x00000000800f4ae4 in __cxa_finalize (dso_handle=0x0) at cxa_atexit.c:222 #8 0x00000000800f4cac in __do_atexit_work () at cxa_atexit.c:229 #9 0x00000000800ff274 in exit (status=0) at vxexit.c:49 #10 0x00000000800001d8 in _start () Forcing a call to get_mutex() earlier during the _Safe_sequence_base ctor forces the mutex destructor to be called in the correct order, but does not seem like a very robust workaround.
next prev parent reply other threads:[~2022-01-25 14:52 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-03-07 13:29 [Bug libstdc++/65343] New: " frankhb1989 at gmail dot com 2015-03-10 12:25 ` [Bug libstdc++/65343] " frankhb1989 at gmail dot com 2022-01-25 14:52 ` poulhies at adacore dot com [this message] 2022-01-25 17:30 ` ebotcazou at gcc dot gnu.org 2022-01-25 20:58 ` redi at gcc dot gnu.org 2022-01-25 21:35 ` poulhies at adacore dot com 2022-01-25 21:36 ` redi at gcc dot gnu.org 2022-01-25 21:38 ` redi at gcc dot gnu.org 2024-02-08 12:40 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-65343-4-5O02iBmXNp@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).