473,378 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

gcc3.2.3 : exception caught, but still segment fault

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.

Jul 23 '05 #1
2 1590
li*****@hotmail.com wrote:
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
Jul 23 '05 #2
li*****@hotmail.com wrote:
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.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jacek Dziedzic | last post by:
Hi! In my main() function I have a last-resort exception construct that looks like this: int main() { try { // ... program code }
1
by: John Black | last post by:
Hi, I have a code using exception, it works great on Solaris using Forte compiler, but on Linux using gcc3.2, there are some strange problem which ends up "segment fault", I am tracking the...
40
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
2
by: rogero | last post by:
I'm having a nasty problem where the destructor of an automatic variable is invoked with the wrong address during stack unwinding. Below is a small example program. Roger Orr -- MVP in C++ at...
11
by: chopsnsauce | last post by:
Here's the example: Dim frm As New FORM1 Try frm.show Catch ex As Exception msgbox ex.message
3
by: Alfred.Cheong | last post by:
I am building a NSS module on Solaris 10 64bit (amd64). It is a dynamic linked library to be invoked by the other programs like the system command ps. The dynamic linked library is build on C++....
10
by: Rahul | last post by:
Hi Everyone, I have the following exception class, class E1 { }; class E2 {
2
by: D'Arcy J.M. Cain | last post by:
I am having a strange problem and I can't seem to zero in on it. I am also having trouble reducing it to a small enough snippet that I can post here. I think that I am doing what the more complex...
0
by: Chris Rebert | last post by:
On Tue, Nov 18, 2008 at 8:56 PM, D'Arcy J.M. Cain <darcy@druid.netwrote: What happens under Python 2.6? Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.