[uClibc]exceptions crash using uclibc but not on glibc
Marc Hoffknecht
Hoffknecht at rogers.com
Tue May 20 13:34:25 UTC 2003
I encountered the same problems. Actually, the test program below seems
enough to cause the failure. The catch() section will never be executed.
#include <stdio.h>
int main() {
try {
throw;
} catch(...) {
printf( "Caught the exception." );
}
return 0;
}
----- Original Message -----
From: "Klaas van Gend" <klaas.vangend at reduct.net>
To: <uclibc at uclibc.org>
Sent: Tuesday, May 20, 2003 8:06 AM
Subject: [uClibc]exceptions crash using uclibc but not on glibc
> Hi everybody,
>
> We've encountered a strange phenomenon when we compile the attached C++
> code in the buildroot environment of March 6, 2003.
>
> (note: the below indentation is mine to distinguish input and output)
>
> Compilation:
> g++ Source1.cpp -o test
> And then run:
> ./test
> The output:
> Parameter a: 13
> *** pre doTest()
> Parameter a: 13
> The shell then displays 'Aborted'. The test code has crashed.
>
> Strangely enough, when I compile the same in a native SuSE 8.0
> environment (gcc 2.95.3) using:
> g++ Source1.cpp -o test80
> And then run:
> ./test80
> Parameter a: 13
> *** pre doTest()
> Parameter a: 13
> *** in catch *** : 13
> *** post doTest()
> *** Main
> This time, the program completes without any problems.
>
> It seems that the throw is behaving badly -> the constructor of the
> Test1 exception is run, but the catch is never executed, the program
> dies before that.
>
> Does anyone have any clues on what is happening here or how to work
> around it ???
>
> Thanks in advance,
>
> Klaas van Gend
>
>
>
>
>
>
----------------------------------------------------------------------------
----
> #include <stdio.h>
> #include <stdlib.h>
>
>
> class Test1
> {
> public:
> Test1(int a);
> int getNum();
> ~Test1();
>
> private:
> int b;
> };
>
> Test1::Test1(int a)
> {
> printf("Parameter a: %d\n", a);
> b = a;
> }
>
> int Test1::getNum()
> {
> return b;
> }
>
> Test1::~Test1()
> {
> ;
> }
>
> class Test2
> {
> public:
> Test2();
> void doTest();
> ~Test2();
> };
>
> Test2::Test2()
> {
> ;
> }
>
> void Test2::doTest()
> {
> try
> {
> throw Test1(13);
> }
> catch(Test1& t)
> {
> printf("*** in catch *** : %d\n", t.getNum());
> }
> }
>
> Test2::~Test2()
> {
> ;
> }
>
> int main()
> {
> Test1 t1(13);
> Test2 t2;
>
> printf("*** pre doTest()\n");
> t2.doTest();
> printf("*** post doTest()\n");
>
> printf("*** Main\n");
> getchar();
>
> return 0;
> }
>
----------------------------------------------------------------------------
----
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://uclibc.org/mailman/listinfo/uclibc
>
More information about the uClibc
mailing list