Bug 17277 - [AIX] could not catch an exception when specified -maix64
Summary: [AIX] could not catch an exception when specified -maix64
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.2
: P1 normal
Target Milestone: 3.4.3
Assignee: Not yet assigned to anyone
Keywords: wrong-code
Depends on:
Reported: 2004-09-02 03:21 UTC by masahiro
Modified: 2014-06-28 16:51 UTC (History)
2 users (show)

See Also:
Host: powerpc-ibm-aix5.2.0.0
Target: powerpc-ibm-aix5.2.0.0
Build: powerpc-ibm-aix5.2.0.0
Known to work:
Known to fail:
Last reconfirmed: 2004-09-09 17:10:26


Note You need to log in before you can comment on or make changes to this bug.
Description masahiro 2004-09-02 03:21:40 UTC
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()
      throw 1;
    } catch( int i ) {
    return 0;
  cleo% g++ -maix32 throw.cc -o throw; ./throw
  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 Andrew 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 3 GCC Commits 2004-09-11 17:10:34 UTC
Subject: Bug 17277

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	dje@gcc.gnu.org	2004-09-11 17:10:25

Modified files:
	gcc            : ChangeLog 
	gcc/config/rs6000: aix.h 

Log message:
	PR target/17277
	* config/rs6000/aix.h (MD_FROB_UPDATE_CONTEXT): Use __64BIT__ to
	choose 64-bit version.


Comment 4 GCC Commits 2004-09-11 17:11:08 UTC
Subject: Bug 17277

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dje@gcc.gnu.org	2004-09-11 17:11:05

Modified files:
	gcc            : ChangeLog 

Log message:
	Add PR target/17277 to ChangeLog entry.


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?