From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 897 invoked by alias); 28 Jan 2010 22:50:11 -0000 Received: (qmail 732 invoked by uid 48); 28 Jan 2010 22:49:56 -0000 Date: Thu, 28 Jan 2010 22:50:00 -0000 Message-ID: <20100128224956.731.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug libstdc++/42679] RTLD_DEEPBIND dlopen option for shared library that uses libstdc++ std::ostream crashes In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jakub at gcc dot gnu dot org" 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/msg03267.txt.bz2 ------- Comment #11 from jakub at gcc dot gnu dot org 2010-01-28 22:49 ------- LD_DEBUG=all ./main 2>&1 | grep _ZSt4cerr 12758: symbol=_ZSt4cerr; lookup in file=./main [0] 12758: binding file /usr/lib64/libstdc++.so.6 [0] to ./main [0]: normal symbol `_ZSt4cerr' [GLIBCXX_3.4] 12758: symbol=_ZSt4cerr; lookup in file=/lib64/libdl.so.2 [0] 12758: symbol=_ZSt4cerr; lookup in file=/usr/lib64/libstdc++.so.6 [0] 12758: binding file ./main [0] to /usr/lib64/libstdc++.so.6 [0]: normal symbol `_ZSt4cerr' [GLIBCXX_3.4] 12758: symbol=_ZSt4cerr; lookup in file=./library.so [0] 12758: symbol=_ZSt4cerr; lookup in file=/usr/lib64/libstdc++.so.6 [0] 12758: binding file ./library.so [0] to /usr/lib64/libstdc++.so.6 [0]: normal symbol `_ZSt4cerr' [GLIBCXX_3.4] The first lookup is for std::cerr relocations in libstdc++, the second one is just to find out what should be the std::cerr COPY relocation in main be initialized for. Thus, the executable uses std::cerr inside of main's .bss. But during RTLD_DEEPBIND first library.so and its dependencies are searched, so the copy in libstdc++.so.6 (which hasn't been initialized at runtime) is used. Note that std::cerr isn't STB_GNU_UNIQUE, so this crashes even on Fedora 12. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42679