AIX:为什么引发异常会中止多线程代码? [英] AIX: Why does throwing an exception abort multithreaded code?

查看:140
本文介绍了AIX:为什么引发异常会中止多线程代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行-pthread编译的代码时,当抛出C ++异常时,我们将中止操作。

We get an abort when a C++ exception is thrown when running code compiled with -pthread.

平台:AIX 5.3技术级别8
编译器:gcc 3.4.6
链接器:AIX链接器1.65.2.4

Platform: AIX 5.3 technical level 8 Compiler: gcc 3.4.6 Linker: AIX linker 1.65.2.4

测试代码:

// exception.cpp
#include <iostream>

class MyException
{
public:
        MyException(){}
        virtual ~MyException(){};
};

void gTest()
{
        throw MyException();
}

int main()
{
        try
        {
                gTest();
        }
        catch(MyException const & ex)
        {
                std::cout << "exception was caught" << std::endl;
        }

        return 0;
}


$ g++ exception.cpp
$ ./a.out
exception was caught
$ g++ -pthread exception.cpp
$ ./a.out
terminate called after throwing an instance of 'MyException'
IOT/Abort trap (core dumped)
$ gdb a.out
GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "powerpc-ibm-aix5.1.0.0"...
(gdb) run
Starting program: /home/leeder/except/a.out
terminate called after throwing an instance of 'MyException'

Program received signal SIGABRT, Aborted.
Switching to Thread 1
0xd0124834 in pthread_kill () from /usr/lib/libpthreads.a(shr_xpg5.o)
(gdb) bt
#0 0xd0124834 in pthread_kill () from /usr/lib/libpthreads.a(shr_xpg5.o)
#1 0xd01242a8 in _p_raise () from /usr/lib/libpthreads.a(shr_xpg5.o)
#2 0xd0359bdc in raise () from /usr/lib/libc.a(shr.o)
#3 0xd03b7efc in abort () from /usr/lib/libc.a(shr.o)
#4 0xd0ca1800 in __gnu_cxx::__verbose_terminate_handler() () at ../../.././libstdc++-v3/libsupc++/vterminate.cc:96
#5 0xd0ca1220 in __cxxabiv1::__terminate(void (*)()) (handler=0)
at ../../.././libstdc++-v3/libsupc++/eh_terminate.cc:43
#6 0xd0ca128c in std::terminate() () at ../../.././libstdc++-v3/libsupc++/eh_terminate.cc:53
#7 0xd0ca7cfc in __cxa_throw (obj=0x200084e8, tinfo=0xffffffff, dest=Cannot access memory at address 0xffffffff
)
at ../../.././libstdc++-v3/libsupc++/eh_throw.cc:80
#8 0x100008dc in gTest() ()
#9 0x100009f0 in main ()
(gdb)

有人看见过类似的东西吗?

Has anyone seen anything similar?

您认为升级到gcc 4会有所帮助吗?

Do you think upgrading to gcc 4 would help?

切换到IBM的xl编译器怎么样?

What about switching to IBM's xl compiler?

谢谢。

推荐答案

g ++ 4.3.2似乎可以解决此问题。 xlC v10也可以。

g++ 4.3.2 seems to work Ok for this problem. Also xlC v10 works.

这篇关于AIX:为什么引发异常会中止多线程代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆