Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#206 Crash using Kernel32 and C++ exceptions

component_package
closed-fixed
Danny Smith
gcc (462)
2005-01-31
2002-10-30
Florin Ghido
No

Hi!

There is a big problem with using Kernel32.dll functions
and C++ exceptions. After calling a Kernel32.dll function
with at least one parameter, the program fails to catch
any C++ exception.
This appears only when compiling with the option:
-fomit-frame-pointer

The command line used is:
gcc -fomit-frame-pointer Test.cpp -lstdc++ -o Test.exe -s

I am using the latest packages:
MinGW-2.0.0-3.exe
binutils-2.13.90-20021006-2.tar.gz

The source.cpp file is:
--------------------------------------
#include <windows.h>

void test()
{
SYSTEMTIME p;
GetSystemTime(&p);
throw 1;
}

int main(int argc,char* argv[])
{
try
{
test();
return 0;
}
catch(...)
{
return 1;
}
}
-----------------------------------------
Running it under W98 SE and W2000 P produces
the following result:

abnormal program termination

Best regards,
Florin Ghido

Discussion

  • Florin Ghido
    Florin Ghido
    2002-10-30

    Test.cpp source file

     
    Attachments
  • Danny Smith
    Danny Smith
    2002-10-30

    Logged In: YES
    user_id=11494

    Thanks for your report and testcase.

    I confirm the bug on GCC 3.3 (CVS) built with with
    Dwarf2 EH handling. The workaround is to add -
    maccumulate-outgoing-args switch when using -fomit-
    frame-pointer with Dwarf 2.

    Could you try that with gcc 3.2 please?

    With same gcc 3.3 source built with sjlj exception
    model, the -fomit-frame-pointer switch works on your
    testcase, _without_ need for -maccumulate-outgoing-
    args switch.

    Have a look at PR 6764 at gnatsweb for another
    testcase that shows the same bug and the same
    workaround.

    Gnatsweb is here:
    http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc

    Also, PR6764 tescase works fine with sjlj exception
    handling.

    Danny

     
  • Danny Smith
    Danny Smith
    2002-10-30

    • assigned_to: earnie --> dannysmith
     
  • Earnie Boyd
    Earnie Boyd
    2003-01-03

    • labels: 103945 --> gcc
    • milestone: --> component_package
    • status: open --> open-remind
     
  • Earnie Boyd
    Earnie Boyd
    2003-01-03

    Logged In: YES
    user_id=15438

    Florin, did you try Danny's suggestion? What was the
    result? Also, please try the gcc-3.2.1 release candidate
    and report your results.

    Thanks,
    Earnie.

     
  • Danny Smith
    Danny Smith
    2004-07-29

    Logged In: YES
    user_id=11494

    A follow up to report status with current (20040728( GCC
    sources and Dwarf2 enabled:

    FAIL
    g++ -O0 -fomit-frame-pointer test.cpp

    PASS
    g++ -O1 -mno-accumulate-outgoing-args -fomit-frame-
    pointer test.cpp
    [and all higher optimization]

    g++ -O[anything] -maccumulate-outgoing-args -fomit-
    frame-pointer test.cpp

    g++ -O[anything] -mno-accumulate-outgoing-args -fno-
    omit-frame-pointer test.cpp

    So its still a problem with Dwarf2, but only when the _only_
    optimizarion is -fomit-frame-pointer

    Danny

     
  • Danny Smith
    Danny Smith
    2005-01-31

    Logged In: YES
    user_id=11494

    This Dwarf2 bug )PR 6764 ) has been fixed in GCC sources.
    Danny

     
  • Danny Smith
    Danny Smith
    2005-01-31

    • status: open-remind --> closed-fixed