17277 – [AIX] could not catch an exception when specified -maix64 (original) (raw)

Exception handling seems completely broken when -maix64 option is specified. I have tried with g++ version 3.4.0, 3.4.1, 3.4.2 20040829 (prerelease) respectively and got the same result. Following is a small test case.

cleo% cat throw.cc #include <stdio.h>

int main() { try{ throw 1; } catch( int i ) { printf("catch\n"); } return 0; } cleo% g++ -maix32 throw.cc -o throw; ./throw catch cleo% g++ -maix64 throw.cc -o throw; ./throw zsh: segmentation fault (core dumped) ./throw

It works fine under -maix32 option, but when we want to compile in 64-bit mode the compiled binary crushes just after throw. I used native ld and as (which are the latest versions). The configure command line is

./configure --enable-languages=c,c++ --disable-nls

Comment 1 Drea Pinski 2004-09-02 05:10:33 UTC

hmm, the only thing remotely close to this is PR 13391 but that delt with shared libraries.

Comment 2 David Edelsohn 2004-09-09 17:09:45 UTC

The correct TOC pointer is not being restored in the exception handler catch block, so the call to __cxa_catch_begin in the shared library through glink code is loading the function address from the wrong TOC. The code works correctly in 32-bit mode and the algorithm is the same, so the failure is very suspicious.

Comment 5 David Edelsohn 2004-09-11 17:11:56 UTC

Fixed in GCC 3.4.3 and mainline.

Comment 6 Krishnamoorthy C 2014-06-28 16:51:19 UTC

The exact same code/application compiles and runs fine on multiple OS's ( HP UX, Windows , Red Hat etc ) , i am seeing the problem only on AIX 7.1

But when you say this problem could be something other than AIX 7.1, could it be the environment variables, or a mismatch in the shared libs used. Btw, a shared lib , compiled with gcc on AIX 7.1, but in C language is also being used.

Would you suggest using a lower verion of the gcc compiler what we used?