From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27656 invoked by alias); 10 Jan 2010 07:26:15 -0000 Received: (qmail 27347 invoked by uid 48); 10 Jan 2010 07:26:01 -0000 Date: Sun, 10 Jan 2010 07:26:00 -0000 Subject: [Bug libstdc++/42679] New: RTLD_DEEPBIND dlopen option for shared library that uses libstdc++ std::ostream crashes X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mjtruog at fastmail dot ca" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-01/txt/msg01115.txt.bz2 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=) 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=) 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=) at malloc.c:5949 #4 0x00002b92e27f80a6 in *__GI___libc_free (mem=0x2b92e28aef40) at malloc.c:3625 #5 0x00002b92e228b0d8 in std::basic_stringbuf, std::allocator >::overflow (this=0x40a87948, __c=) 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 >::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 > (__out=@0x40a87940, __s=, __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=, variable1=, variable2=, variable3=, variable4=, 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=, 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=) 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::run (this=) 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=) 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