Missing inline -> uncaught exception (AIX & shared libs)

Joerg.Richter@pdv-FS.de Joerg.Richter@pdv-FS.de
Wed Sep 10 10:06:00 GMT 2003


Hi again,

I finally tracked my problem from last week down to a simple missing inline.

Look at this testcase with two source files and the commands to build them:

---- main.cc ----

void inlineFunc()       // note: missing inline
{
}

void throwingFunc();

int
main()
{
  try
  {
    throwingFunc();
  }
  catch( ... )
  {
  }
  return 0;
}

---- shared.cc ----

void inlineFunc()       // note: missing inline
{
}

void throwingFunc()
{
  throw 5;
}

---- build ----

GCC=/tools/pkg/gcc/3.3.1/bin/g++

set -x
rm -f *.o *.a *.so main

sudo slibclean
$GCC -c -o shared.o shared.cc
$GCC -shared -Wl,-G -o libshared.so shared.o

$GCC -c -o main.o main.cc
$GCC -Wl,-brtl -L. -o main main.o -lshared

---- end ----

When executing main you will get:
IOT/Abort trap(coredump)

Backtrace with gdb gets you

#0  0xd01dcf38 in raise ()
#1  0xd01eb9dc in abort ()
#2  0xd71168c8 in _ZN10__cxxabiv111__terminateEPFvvE (handler=<incomplete
type>) at  _start_ :47
#3  0xd711687c in _ZSt9terminatev () at  _start_ :57
#4  0xd711b5e4 in __cxa_throw (obj=<incomplete type>, tinfo=<incomplete
type>, dest=<incomplete type>) at  _start_ :80
#5  0xd5f7c218 in _Z12throwingFuncv ()
#6  0x100003a4 in main ()
#7  0x100001dc in __start ()

You see that the the catch in main is not considered to handle the
exception.


You will get a warning for duplicate symbols when linking main:

ld: 0711-224 WARNING: Duplicate symbol: .inlineFunc()
ld: 0711-224 WARNING: Duplicate symbol: _GLOBAL__F__Z10inlineFuncv
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.

Yes, in this testcase I could have seen from the warning that there is
something wrong. But first you don't see the warnings when you dlopen the
library and second http://gcc.gnu.org/install/specific.html#*-ibm-aix* says
that it is ok when you get warnings. In real world applications I also get
warnings about duplicate functions with inline keywords. So this can't be
used to find the error.

I know that the code above is wrong. But I spent nearly a week to track this
failure down to the relevant code in our project. This failure also
sometimes disappears when exchanging the order of two includes, the order of
the objects as they are linked into a library or changing the optimization
level. This all makes it extremly difficult to find the error. From the
testcase you also see that the duplicate function is never called. So the
stacktrace doesn't help either to find the missing inline.

So I think it is an QoI issue. I heard and read of other users with the same
problem. I think some of them don't use GCC on AIX because of this problem
and they think the compiler is broken. I really like the GCC. So I hope you
can do anything to make this work.

I see some possible solutions:

1. Get rid of all the warnings the page above talks about so that you can
see the real warnings. (but you still don't see them when dlopen'ing a lib)
2. Make the exception mechanism work even when there are multiple
definitions of the same function.
3. do nothing because GCC works correct with iso c++ source.


Please let me know if I can help you further.


I tried version 3.2.1 and 3.3.1. Both behave the same way.

$ g++ -v
Reading specs from
/tools/pkg/gcc/3.3.1/lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.3.1/specs
Configured with: ../gcc-3.3.1/configure --prefix=/tools/pkg/gcc/3.3.1
--with-ld=/bin/ld --with-as=/bin/as --enable-languages=c,c++
Thread model: aix
gcc version 3.3.1


  Joerg Richter



More information about the Gcc mailing list