* gcc3.2.3 : exception caught, but still segment fault
@ 2005-05-19 2:27 lin q
2005-05-19 8:58 ` Fred Labrosse
0 siblings, 1 reply; 4+ messages in thread
From: lin q @ 2005-05-19 2:27 UTC (permalink / raw)
To: gcc-help
OK, I have some update on this.
I find that I must use "catch (...)" to catch the exception, otherwise there
always is a segment fault.
I tried throw an integer and catch an integer, throw a string and catch a
string and that throw a self-defined class object and catch that class,
these all do not work.
I tried tracing the flow in gdb, but it can only go to the catch statement
and then I see something about SIGNAL and flow lost.
But once I use "catch (..)" then whatever type is thrown, it is fine.
It is strange. Any body see it?
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 wonder
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gcc3.2.3 : exception caught, but still segment fault
2005-05-19 2:27 gcc3.2.3 : exception caught, but still segment fault lin q
@ 2005-05-19 8:58 ` Fred Labrosse
0 siblings, 0 replies; 4+ messages in thread
From: Fred Labrosse @ 2005-05-19 8:58 UTC (permalink / raw)
To: gcc-help
On Wed, 18 May 2005 20:27:52 -0600
"lin q" <linq936@hotmail.com> wrote:
> OK, I have some update on this.
>
> I find that I must use "catch (...)" to catch the exception, otherwise
> there always is a segment fault.
What do you mean by "catch (...)"? You do have one in the code you
sent.
Fred
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gcc3.2.3 : exception caught, but still segment fault
2005-05-18 21:46 lin q
@ 2005-05-18 23:41 ` Eljay Love-Jensen
0 siblings, 0 replies; 4+ messages in thread
From: Eljay Love-Jensen @ 2005-05-18 23:41 UTC (permalink / raw)
To: lin q, gcc-help
Hi lin q,
Use gdb to step through the problem area. Set break points inside your catch handler.
I suspect that the caller of func() is dereferecing the NULL pointer, causing a segment fault.
HTH,
--Eljay
^ permalink raw reply [flat|nested] 4+ messages in thread
* gcc3.2.3 : exception caught, but still segment fault
@ 2005-05-18 21:46 lin q
2005-05-18 23:41 ` Eljay Love-Jensen
0 siblings, 1 reply; 4+ messages in thread
From: lin q @ 2005-05-18 21:46 UTC (permalink / raw)
To: gcc-help
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 wonder
_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee®
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-05-19 8:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-19 2:27 gcc3.2.3 : exception caught, but still segment fault lin q
2005-05-19 8:58 ` Fred Labrosse
-- strict thread matches above, loose matches on Subject: below --
2005-05-18 21:46 lin q
2005-05-18 23:41 ` Eljay Love-Jensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).