Project

General

Profile

Actions

Bug #1997

closed

C++ exception handling problems with -m64?

Added by Justin Santa Barbara almost 10 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Start date:
2012-01-18
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

I'm having some problems with C++ and -m64, where it works with -m32. I'm running OI151a with GCC 4.6.2 from SFE. The exception is caught with -m32 (as expected), but with -m64 it is not caught and terminate is called. Simple test case below:

mkdir test2
cd test2
cat > test.cc <<EOF
#include <memory>
#include <iostream>
#include <stdexcept>

using namespace std;

int main() {
try {
throw invalid_argument("Hello world");
} catch (exception& e) {
cerr << "Caught exception\n";
}
return 0;
}
EOF

g++ -m32 test.cc; ./a.out
  1. Caught exception
g++ -m64 test.cc; ./a.out
  1. terminate called after throwing an instance of 'std::invalid_argument'
  2. Abort (core dumped)

uname -a
#SunOS openindiana 5.11 oi_151a i86pc i386 i86pc Solaris

g++ --version
#g++ (GCC) 4.6.2

Actions #1

Updated by Justin Santa Barbara almost 10 years ago

This looks to be related to library loading order:

http://paulbeachsblog.blogspot.com/2008/03/exceptions-gcc-and-solaris-10-amd-64bit.html
https://forums.oracle.com/forums/thread.jspa?threadID=2191106

As suggested in the second post, forcing library resolution to gcc_s does fix the problem.
LD_PRELOAD=/usr/sfw/lib/amd64/libgcc_s.so.1 ./a.out

However, I can't quite figure out how to convert this into a working fix.

Actions #2

Updated by Ken Mays almost 10 years ago

  • Status changed from New to Feedback
  • Assignee set to Alex Viskovatoff

Using Justin's code with SFEgcc 4.6.1,REV=110.0.4.2011.08.23.23.47

1. g++ -m32 testgcc.cc : PASS
2. g++ -m64 testgcc.cc : PASS

Talk to Thomas Wagner/Milan Jurik about pkg: ,5.11-0.151.1:20111222T011404Z

Actions #3

Updated by Ken Mays over 8 years ago

  • Status changed from Feedback to Closed
  • Assignee changed from Alex Viskovatoff to Ken Mays
  • % Done changed from 0 to 100

Rested with ,5.11-0.151.1.5:20120727T211200Z. Closing ticket.

Actions

Also available in: Atom PDF