在Solaris 11上使用g ++ 5.4编译时,Solaris 10上未捕获C ++异常

时间:2019-05-14 20:48:56

标签: c++ exception g++ solaris

我正在Solaris 11上使用g ++ 5.4进行编译,并在Solaris 10上运行。除了未捕获的C ++异常外,其他所有东西似乎都可以正常工作。

在Solaris 11上:

这是我的编译器和操作系统版本:

$ uname -a
SunOS tf-vdevmcps11-d001 5.11 11.3 i86pc i386 i86pc
$ g++ --version
g++ (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

一个简单的测试程序。

  

$ cat foo.cxx

#include <iostream>

int main()
{
        try {
                throw 15; // f();
                std::cout << "after f\n";
        } catch (int i) {
                std::cout << "caught " << i << '\n';
        } catch (...) {
                std::cout << "caught unknown exception\n";
        }
}

它可以在此处编译并正常运行:

$ g++ -fabi-version=2 -Wabi -o foo -g -m32 foo.cxx
$ ./foo
caught 15

这些是它使用的动态库:

$ ldd foo
        libstdc++.so.6 =>        /usr/lib/libstdc++.so.6
        libm.so.2 =>     /lib/libm.so.2
        librt.so.1 =>    /lib/librt.so.1
        libgcc_s.so.1 =>         /usr/lib/libgcc_s.so.1
        libc.so.1 =>     /lib/libc.so.1

在Solaris 10上它崩溃:

$ ./foo
terminate called after throwing an instance of 'int'
Abort(coredump)

这是核心文件的堆栈跟踪

$ pstack core
core 'core' of 10550:   ./foo
 fecca427 _lwp_kill (1, 6) + 7
 fec720c3 raise    (6) + 1f
 fec51d2d abort    (feffdd68, 9844246, 806ac20, fed40c10, 0, 0) + cd
 fef24565 _ZN9__gnu_cxx27__verbose_terminate_handlerEv (0, feff0488, fef211cb, fef65e28, 8066240, 8047c30) + 175
 fef211d7 _ZN10__cxxabiv111__terminateEPFvvE (fef243f0, 0, fef21235, fef21267, fef21259, fef65e28) + 17
 fef21270 _ZN10__cxxabiv112__unexpectedEPFvvE (8066240, feff0488, fef21235, fef214cf, feffb818, 8047b6c)
 fef214fe ???????? (8066260, 8061740, 0, fed32a40, 8047b80, fefcab34)
 08051239 main     (8051379, feffb818, 8047ba4, 8051053, 1, 8047bb0) + 35
 08051053 _start   (1, 8047c98, 0, 8047c9e, 8047ca6, 8047cad) + 83

以下是动态库:

$ ldd foo
        libstdc++.so.6 =>        /opt/csw/lib/libstdc++.so.6
        libm.so.2 =>     /usr/lib/libm.so.2
        librt.so.1 =>    /usr/lib/librt.so.1
        libgcc_s.so.1 =>         /opt/csw/lib/libgcc_s.so.1
        libc.so.1 =>     /usr/lib/libc.so.1
        libaio.so.1 =>   /usr/lib/libaio.so.1
        libmd.so.1 =>    /usr/lib/libmd.so.1

两个GNU库来自该软件包的5.5版本:

>$ pkginfo -l CSWlibgcc-s1 CSWlibstdc++6
   PKGINST:  CSWlibgcc-s1
      NAME:  libgcc_s1 - The GNU Compiler Collection, libgcc_s.so.1
  CATEGORY:  application
      ARCH:  i386
   VERSION:  5.5.0,REV=2017.10.23
   BASEDIR:  /
    VENDOR:  http://gcc.gnu.org packaged for CSW by Dagobert Michelsen
    PSTAMP:  dam@unstable10x-20171023221120
  INSTDATE:  Apr 22 2019 08:14
   HOTLINE:  http://www.opencsw.org/bugtrack/
     EMAIL:  dam@opencsw.org
    STATUS:  completely installed
     FILES:        4 installed pathnames
                   1 directories
                1883 blocks used (approx)

   PKGINST:  CSWlibstdc++6
      NAME:  libstdc++6 - The GNU Compiler Collection, libstdc++.so.6
  CATEGORY:  application
      ARCH:  i386
   VERSION:  5.5.0,REV=2017.10.23
   BASEDIR:  /
    VENDOR:  http://gcc.gnu.org packaged for CSW by Dagobert Michelsen
    PSTAMP:  dam@unstable10x-20171023221408
  INSTDATE:  Apr 22 2019 08:06
   HOTLINE:  http://www.opencsw.org/bugtrack/
     EMAIL:  dam@opencsw.org
    STATUS:  completely installed
     FILES:        6 installed pathnames
                   1 directories
                   2 executables
               43873 blocks used (approx)

0 个答案:

没有答案