gcc3.2.3 : exception caught, but still segment fault

L

linq936

Hi,
I am using gcc3.2.3 as the compiler for my c++ code on Red Hat Linux
Enterprise 3. I find that even an exception is caught, "Segment Fault"
is still thrown out and program crashes.

Here is my code,
int func0(){
...
if (...some condition...){
throw MyException();
}
}

char* func(){
try{
...
func0();
}
catch (MyException& ){
cout << "Hey catch exception" << endl;
return NULL;
}
}

In running the code, I can see that "Hey catch exception", and then
"Segment Fault", it never returns to the caller of func().

Is this a known problem?

Thanks.
 
V

Victor Bazarov

I am using gcc3.2.3 as the compiler for my c++ code on Red Hat Linux
Enterprise 3. I find that even an exception is caught, "Segment Fault"
is still thrown out and program crashes.

Here is my code,
int func0(){
...
if (...some condition...){
throw MyException();
}
}

char* func(){
try{
...
func0();
}
catch (MyException& ){
cout << "Hey catch exception" << endl;
return NULL;
}
}

In running the code, I can see that "Hey catch exception", and then
"Segment Fault", it never returns to the caller of func().

Is this a known problem?

How can it be answered if we don't know what 'MyException' is and how you
call the 'func' and what you do with the return value. Besides, the code
you posted contains instances of '...' which also can be the cause of the
faults.

BTW, not all control paths in 'func' have the 'return' statements.

Follow the recommendations in FAQ 5.8.

V
 
R

red floyd

Hi,
I am using gcc3.2.3 as the compiler for my c++ code on Red Hat Linux
Enterprise 3. I find that even an exception is caught, "Segment Fault"
is still thrown out and program crashes.

Here is my code,
int func0(){
...
if (...some condition...){
throw MyException();
}
}

char* func(){
try{
...
func0();
}
catch (MyException& ){
cout << "Hey catch exception" << endl;
return NULL;
}
}

In running the code, I can see that "Hey catch exception", and then
"Segment Fault", it never returns to the caller of func().

Is this a known problem?

Thanks.

I had a similar problem. By any chance do you have MATLAB installed?

Note: Followup set to gnu.g++.help, since this is OT for c.l.c++.
Please continue reading this thread there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top