public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/42679]  New: RTLD_DEEPBIND dlopen option for shared library that uses libstdc++ std::ostream crashes
@ 2010-01-10  7:26 mjtruog at fastmail dot ca
  2010-01-10 10:42 ` [Bug libstdc++/42679] " paolo dot carlini at oracle dot com
                   ` (17 more replies)
  0 siblings, 18 replies; 26+ messages in thread
From: mjtruog at fastmail dot ca @ 2010-01-10  7:26 UTC (permalink / raw)
  To: gcc-bugs

I do not know why this occurs but it only seems to occur for libstdc++
std::ostream code.  I have had SEGFAULTs with std::cerr but not std::clog when
simply outputting errors but tried to ignore it... until I found a different
problem.  I was getting SIGABRTs from a free() assert within libc when using
std::ostringstream for simple stream operators building from static 'char const
* const' like:

std::ostringstream s;
s << "bad";

I don't have a simple test to replicate this unfortunately, but I do have an
example crash dump.  I was using the linker -rpath to always tie the executable
and the shared library to the gcc dependencies.  I have no problems with my
setup when I remove the dlopen RTLD_DEEPBIND option when loading my shared
library that includes the std::ostream usage (like that which I described for
std::ostringstream).  This particular problem is a "heisenbug" because it only
appears when I turn optimization on for the shared library (-O1 was enough to
make it crash).  The example crash dump is below:

#0  0x00002b92e27af015 in *__GI_raise (sig=<value optimized out>)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
        in ../nptl/sysdeps/unix/sysv/linux/raise.c
(gdb) back
#0  0x00002b92e27af015 in *__GI_raise (sig=<value optimized out>)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00002b92e27b0b83 in *__GI_abort () at abort.c:88
#2  0x00002b92e27f00c8 in __libc_message (do_abort=2, 
    fmt=0x2b92e28b8dd0 "*** glibc detected *** %s: %s: 0x%s ***\n")
    at ../sysdeps/unix/sysv/linux/libc_fatal.c:170
#3  0x00002b92e27f5a58 in malloc_printerr (action=2, 
    str=0x2b92e28b63a9 "free(): invalid pointer", ptr=<value optimized out>)
    at malloc.c:5949
#4  0x00002b92e27f80a6 in *__GI___libc_free (mem=0x2b92e28aef40)
    at malloc.c:3625
#5  0x00002b92e228b0d8 in std::basic_stringbuf<char, std::char_traits<char>,
std::allocator<char> >::overflow (this=0x40a87948, __c=<value optimized out>)
    at
/.../src/lib/g++/releases/gcc-4.4.2/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:231
#6  0x00002b92e228eee5 in std::basic_streambuf<char, std::char_traits<char>
>::xsputn (this=0x40a87948, 
    __s=0xeea868
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567
", __n=98)
    at
/.../src/lib/g++/releases/gcc-4.4.2/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/streambuf.tcc:97
#7  0x00002b92e22871d5 in std::__ostream_insert<char, std::char_traits<char> >
    (__out=@0x40a87940, __s=<value optimized out>, __n=98)
    at
/.../src/lib/g++/releases/gcc-4.4.2/x86_64-unknown-linux-gnu/libstdc++-v3/include/streambuf:427
#8  0x00002aaaaaab1998 in random_task (stop=@0xeaf7a2, 
    variable0=<value optimized out>, 
    variable1=<value optimized out>, 
    variable2=<value optimized out>, 
    variable3=<value optimized out>, 
    variable4=<value optimized out>, variable5=0, 
    variable6=0, variable7=0, variable8=0, 
    variable9=0, variable10=0, variable11=0, 
    variable12=0, stream=@0x40a87cf0)
    at
/.../install/g++/releases/gcc-4.4.2_install/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.4.2/../../../../include/c++/4.4.2/bits/basic_string.h:2506
#9  0x00002aaaaaabd543 in do_work (stop=<value optimized out>, id=0, 
    taskData=@0xe9d8a0, taskDataSize=88, queriesOut=@0x40a87f70)
    at lib/cloud_job_all_patterns/src/cloud_job_random_task.cpp:106
#10 0x000000000041320d in
WorkerController::WorkerExecution::ThreadPool::ThreadFunctionObject::operator()
(this=0x40a88030, stopped=@0xeaf7a2, 
    allocator=<value optimized out>)
    at lib/cloud_worker/src/worker_execution.cpp:501
warning: (Internal error: pc 0x418d35 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x418d35 in read in psymtab, but not in symtab.)

#11 0x0000000000418d36 in
boost::detail::thread_data<WorkerController::WorkerExecution::ThreadPool::ThreadObject>::run
(this=<value optimized out>)
    at lib/cloud_worker/src/worker_execution.cpp:236
warning: (Internal error: pc 0x418d35 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x418c80 in read in psymtab, but not in symtab.)

#12 0x00002b92e15ae350 in thread_proxy ()
   from
/.../src/lib/boost/releases/boost_1_40_0_install/lib/libboost_thread.so.1.40.0
#13 0x00002b92e2d0c3ea in start_thread (arg=<value optimized out>)
    at pthread_create.c:297
#14 0x00002b92e2862cbd in clone () from /usr/lib/debug/libc.so.6
#15 0x0000000000000000 in ?? ()


libc gives its own little backtrace:
*** glibc detected *** _release/lib/cloud-0.0.8/priv/cloud_worker_port: free():
invalid pointer: 0x00002b92e24e50a0 ***
======= Backtrace: =========
/usr/lib/debug/libc.so.6[0x2b92e27f5a58]
/usr/lib/debug/libc.so.6(cfree+0x76)[0x2b92e27f80a6]
/.../src/lib/g++/releases/gcc-4.4.2_install/lib64/libstdc++.so.6(_ZNSt15basic_stringbufIcSt11char_traitsIcESaIcEE8overflowEi+0x168)[0x2b92e228b0d8]
/.../src/lib/g++/releases/gcc-4.4.2_install/lib64/libstdc++.so.6(_ZNSt15basic_streambufIcSt11char_traitsIcEE6xsputnEPKcl+0x35)[0x2b92e228eee5]
_release/lib/cloud-0.0.8/priv/work_types/libcloud_job_random_task.so(_Z21random_taskRKbP7pg_connRKSsS4_jjjjjjjjjjRSo+0x229)[0x2aaaaaab1998]
_release/lib/cloud-0.0.8/priv/work_types/libcloud_job_random_task.so(do_work+0x74a)[0x2aaaaaabd543]
release/lib/cloud-0.0.8/priv/cloud_worker_port[0x41320d]

You could probably replicate my scenario with the code I am using, but the
setup would be a pain (code is at
http://sourceforge.net/projects/cloudi/files/0.0.8a/cloudi-0.0.8.tar.gz/download)

Why won't std::ostream classes play well with when loaded into an executable
with RTLD_DEEPBIND?  Isn't this some sort of design problem within the
std::ostream code?


-- 
           Summary: RTLD_DEEPBIND dlopen option for shared library that uses
                    libstdc++ std::ostream crashes
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mjtruog at fastmail dot ca
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42679


^ permalink raw reply	[flat|nested] 26+ messages in thread
[parent not found: <bug-42679-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2021-10-15 13:35 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-10  7:26 [Bug libstdc++/42679] New: RTLD_DEEPBIND dlopen option for shared library that uses libstdc++ std::ostream crashes mjtruog at fastmail dot ca
2010-01-10 10:42 ` [Bug libstdc++/42679] " paolo dot carlini at oracle dot com
2010-01-10 18:16 ` mjtruog at fastmail dot ca
2010-01-10 19:18 ` paolo dot carlini at oracle dot com
2010-01-12 15:52 ` paolo dot carlini at oracle dot com
2010-01-22  7:10 ` mjtruog at fastmail dot ca
2010-01-28  3:10 ` paolo dot carlini at oracle dot com
2010-01-28  8:03 ` jakub at gcc dot gnu dot org
2010-01-28  9:50 ` paolo dot carlini at oracle dot com
2010-01-28 20:01 ` jason at gcc dot gnu dot org
2010-01-28 22:07 ` jakub at gcc dot gnu dot org
2010-01-28 22:35 ` paolo dot carlini at oracle dot com
2010-01-28 22:50 ` jakub at gcc dot gnu dot org
2010-01-28 23:00 ` paolo dot carlini at oracle dot com
2010-01-29  0:47 ` paolo dot carlini at oracle dot com
2010-01-29  7:52 ` jakub at gcc dot gnu dot org
2010-01-29 10:08 ` paolo dot carlini at oracle dot com
2010-01-29 17:05 ` mjtruog at fastmail dot ca
2010-03-07 17:53 ` mjtruog at fastmail dot ca
     [not found] <bug-42679-4@http.gcc.gnu.org/bugzilla/>
2010-12-29  6:25 ` liguanglei at gmail dot com
2010-12-29 23:51 ` redi at gcc dot gnu.org
2013-01-02  1:41 ` gauryogesh.nsit at gmail dot com
2013-01-04 10:58 ` redi at gcc dot gnu.org
2013-02-05 23:47 ` mjtruog at fastmail dot ca
2021-10-15 13:29 ` jeanmichael.celerier at gmail dot com
2021-10-15 13:35 ` jeanmichael.celerier at gmail dot com

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).