BUG? -fomit-frame-pointer and exceptions or setjmp/longjmp

Nix nix@esperi.demon.co.uk
Mon Jun 10 14:17:00 GMT 2002


On Sun, 2 Jun 2002, Richard Henderson said:
> On Mon, Jun 03, 2002 at 03:29:31AM +0600, Denis Zaitsev wrote:
>> If gcc is built with the -fomit-frame-pointer in the environment's
>> CXXFLAGS, then we have a dead exception handling mechanics - a c++
>> program, compiled with such a gcc, can't catch any of an exceptions it
>> throws.
> 
> If true, that's a bug.  The frame pointer is NOT necessary to
> throw or catch exceptions.

I see similar things happening inside GiNaC-1.0.8, on an i586, only when
GiNaC is built with -fomit-frame-pointer:

loki 506 /usr/packages/GiNaC/i586-loki/check% ./exams 
GNU gdb 5.2
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-pc-linux-gnu"...(no debugging symbols found)...
(gdb) run
Starting program: /usr/packages/GiNaC/i586-loki/check/.libs/lt-exams 
(no debugging symbols found)...
Program received signal SIGSEGV, Segmentation fault.
0x402b1b16 in uw_frame_state_for (context=0xbffff360, fs=0xbffff2a0) at /usr/packages/gcc/3.1/gcc/unwind-dw2.c:910
910           MD_FALLBACK_FRAME_STATE_FOR (context, fs, success);
(gdb) bt
#0  0x402b1b16 in uw_frame_state_for (context=0xbffff360, fs=0xbffff2a0) at /usr/packages/gcc/3.1/gcc/unwind-dw2.c:910
#1  0x402b2108 in _Unwind_RaiseException (exc=0x81952a0) at /usr/packages/gcc/3.1/gcc/unwind.inc:93
#2  0x40289d48 in __cxa_throw (obj=0x81952a0, tinfo=0x402ada20, dest=0x402ada20 <globals_static>)
    at /usr/packages/gcc/3.1/libstdc++-v3/libsupc++/eh_throw.cc:72
#3  0x40116346 in GiNaC::power::eval(int) const () from /usr/packages/GiNaC/i586-loki/ginac/.libs/libginac-1.0.so.0
#4  0x4005fa8c in GiNaC::ex::construct_from_basic(GiNaC::basic const&) () from /usr/packages/GiNaC/i586-loki/ginac/.libs/libginac-1.0.so.0
#5  0x08060788 in std::__simple_alloc<GiNaC::ex, std::__default_alloc_template<true, 0> >::deallocate(GiNaC::ex*, unsigned) ()
#6  0x404a67f9 in __libc_start_main () from /lib/libc.so.6
#7  0xf0e48350 in ?? ()

I've isolated the throw that causes the crash, but haven't finished
trimming the thing down to a reproducible testcase of sane size. (The
throw at fault is on line 345 of power.cpp, the pow(0,0)-undefined
error case.)

As the trace shows, this crash occurs during unwinding, the presence or
absence of a catch is irrelevant. I'm rather wondering why we're hitting
MD_FALLBACK_FRAME_STATE_FOR at all: perhaps there's a problem in FDE
generation or something. (The fallback looks, er, odd to my eyes: diffing
assembler opcodes by hand just looks *ugly*.)

(Note that there are constructors, MI, and inlined functions at play
here.)


Tracking this down some more is on my to-do list if nobody else gets
there first: it might be related to the huge mass of g++ test failures
(in which exception throwing crashes) you get if GCC is built with
-fomit-frame-pointer.

-- 
`What happened?'
                 `Nick shipped buggy code!'
                                             `Oh, no dinner for him...'



More information about the Gcc mailing list