سؤال

ونحن الحصول على إحباط عندما يتم طرح استثناء C ++ عند تشغيل التعليمات البرمجية المترجمة مع -pthread.

ومنهاج: AIX 5.3 المستوى الفني 8 مترجم: 3.4.6 دول مجلس التعاون الخليجي رابط: AIX رابط 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)

وقد أي شخص ينظر إلى أي شيء مماثل؟

هل تعتقد الترقية إلى دول مجلس التعاون الخليجي 4 من شأنها أن تساعد؟

وماذا عن التحول إلى مترجم الحادي عشر آي بي إم؟

وشكرا.

هل كانت مفيدة؟

المحلول 2

وز ++ 4.3.2 يبدو للعمل طيب لهذه المشكلة. أيضا XLC V10 الأعمال.

نصائح أخرى

وحاول البرنامج على AIX:

<اقتباس فقرة>   

وoslevel -r

     

و5200-08

ومع g ++ --version

<اقتباس فقرة>   

وز ++ (GCC) 3.3.2

     

وز ++ -o السابق -pthread ex.cpp

وسيؤدي إلى حرف لم يتم العثور في وقت التشغيل (pthread_mutex_t)

ولكن إذا كنت بناء عليه مثل:

<اقتباس فقرة>   

وز ++ -o السابق -lpthread ex.cpp

ويعمل على ما يرام مع الآثار المتوقعة. أعتقد أن هذا قد يكون هناك مشكلة الارتباط مع المكتبات pthread الصحيحة.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top