Bug #1997
closedC++ exception handling problems with -m64?
100%
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
- Caught exception
- terminate called after throwing an instance of 'std::invalid_argument'
- Abort (core dumped)
uname -a
#SunOS openindiana 5.11 oi_151a i86pc i386 i86pc Solaris
g++ --version
#g++ (GCC) 4.6.2
Updated by Justin Santa Barbara over 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.
Updated by Ken Mays over 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: runtime/gcc@4.6.2,5.11-0.151.1:20111222T011404Z
Updated by Ken Mays over 9 years ago
- Status changed from Feedback to Closed
- Assignee changed from Alex Viskovatoff to Ken Mays
- % Done changed from 0 to 100
Rested with sfe/developer/gcc@4.6.3,5.11-0.151.1.5:20120727T211200Z. Closing ticket.