From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16716 invoked by alias); 23 Nov 2013 16:13:02 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 16591 invoked by uid 89); 23 Nov 2013 16:13:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RDNS_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-oa0-f51.google.com Received: from Unknown (HELO mail-oa0-f51.google.com) (209.85.219.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 23 Nov 2013 16:11:48 +0000 Received: by mail-oa0-f51.google.com with SMTP id i7so2648531oag.24 for ; Sat, 23 Nov 2013 08:11:40 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.33.74 with SMTP id p10mr16082695oei.18.1385223100673; Sat, 23 Nov 2013 08:11:40 -0800 (PST) Received: by 10.182.105.69 with HTTP; Sat, 23 Nov 2013 08:11:40 -0800 (PST) In-Reply-To: References: Date: Sat, 23 Nov 2013 16:40:00 -0000 Message-ID: Subject: Re: C++ exceptions From: vijay nag To: Ian Lance Taylor Cc: Jonathan Wakely , "gcc-help@gcc.gnu.org" Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00190.txt.bz2 On Sat, Nov 23, 2013 at 1:10 AM, Ian Lance Taylor wrote: > On Thu, Nov 21, 2013 at 1:20 AM, vijay nag wrote: >> >> I tried creating a small binary to demonstrate the problem that I had >> been facing with my gcc-4.7.2 tool chain and glibc-2.17. The library >> and binaries were created using exact CFLAGS, CXXFLAGS et al. >> Strangely, the problem doesn't manifest in my example program :(. On >> further hacking and debugging libgcc, I found that >> _Unwind_RaiseException() was always "returning" in failure case with >> return code _URC_END_OF_STACK. Does it mean that FDE is missing for >> the function which is suppose to catch the exception ? How do I check >> if an FDE exists for a particular function or not ? > > You can use readelf --debug=frames to examine the unwind information > in an executable or object file. > > Ian Ok I found the problem. There seems to exist stack similar stack unwind definition in glibc as well and linker was picking definitions from libc rather than from libgcc_s.so since libc was first in the default link order although I don't understand why linker is not throwing multiple definition error. Back-trace at libgcc/unwind in a normal working application was (gdb) bt #0 _Unwind_Find_FDE (pc=0xb7eb47f8 <_Unwind_RaiseException+56>, bases=0xbffff174) at ../../../../gcc/libgcc/unwind-dw2-fde-dip.c:451 #1 0xb7eb3e21 in uw_frame_state_for (context=context@entry=0xbffff120, fs=fs@entry=0xbffff010) at ../../../../gcc/libgcc/unwind-dw2.c:1179 #2 0xb7eb4362 in uw_init_context_1 (context=context@entry=0xbffff120, outer_cfa=outer_cfa@entry=0xbffff300, outer_ra=0xb7f40201 <__cxxabiv1::__cxa_throw(void*, std::type_info*, void (*)(void*))+97>) at ../../../../gcc/libgcc/unwind-dw2.c:1500 #3 0xb7eb47f9 in _Unwind_RaiseException (exc=0x52048) at ../../../../gcc/libgcc/unwind.inc:88 #4 0xb7f40201 in __cxxabiv1::__cxa_throw (obj=0x52068, tinfo=0x51780 <_ZTIi@@CXXABI_1.3>, dest=0x0) at ../../../../../gcc/libstdc++-v3/libsupc++/eh_throw.cc:78 #5 0x00048d41 in PrintException () at exception/Exception.cpp:26 #6 0x00048ce0 in main () at exception/main.c:27 (gdb) and Back-trace at glibc/unwind in a non-working application (gdb) bt #0 _Unwind_Find_FDE (pc=0xb7d217f8 <_Unwind_RaiseException+56>, bases=0xbfffb8d4) at ../sysdeps/generic/unwind-dw2-fde-glibc.c:253 #1 0xb7d20e21 in uw_frame_state_for (context=context@entry=0xbfffb880, fs=fs@entry=0xbfffb770) at ../../../../gcc/libgcc/unwind-dw2.c:1179 #2 0xb7d21362 in uw_init_context_1 (context=context@entry=0xbfffb880, outer_cfa=outer_cfa@entry=0xbfffba60, outer_ra=0xb7f40201 <__cxxabiv1::__cxa_throw(void*, std::type_info*, void (*)(void*))+97>) at ../../../../gcc/libgcc/unwind-dw2.c:1500 #3 0xb7d217f9 in _Unwind_RaiseException (exc=0x172a3bd0) at ../../../../gcc/libgcc/unwind.inc:88 #4 0xb7f40201 in __cxxabiv1::__cxa_throw (obj=0x172a3bf0, tinfo=0x151ea200 <_ZTIi@@CXXABI_1.3>, dest=0x0) at ../../../../../gcc/libstdc++-v3/libsupc++/eh_throw.cc:78 So I had to explicitly specify this order "-Wl,--start-group -lgcc_s -lgcc -lc -Wl,--end-group" in linker command line arguments to pick-up definitions from libgcc_s.so rather than from libc.