gcc3.2.3 : exception caught, but still segment fault

Discussion in 'C++' started by linq936@hotmail.com, May 18, 2005.

  1. Guest

    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.
    , May 18, 2005
    #1
    1. Advertising

  2. 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
    Victor Bazarov, May 18, 2005
    #2
    1. Advertising

  3. red floyd Guest

    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.
    red floyd, May 18, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ola
    Replies:
    0
    Views:
    522
  2. Tedka
    Replies:
    2
    Views:
    2,656
    Mr. Dot Net
    Jul 19, 2004
  3. John Black
    Replies:
    1
    Views:
    336
    Karthiik Kumar
    Aug 28, 2004
  4. Juggernaut

    Segment fault with pointer to method

    Juggernaut, Apr 11, 2005, in forum: C Programming
    Replies:
    3
    Views:
    354
    Juggernaut
    Apr 11, 2005
  5. Brian
    Replies:
    2
    Views:
    105
    Aaron Bertrand - MVP
    Jul 11, 2003
Loading...

Share This Page