Menu

#168 unhandled exception filter not called in 64-bit

closed-fixed
nobody
None
5
2011-12-16
2010-05-21
No

The Windows API function SetUnhandledExceptionFilter() lets you set a function, that is being called in case of unhandled exception. But this is only called with the 32-bit version of mingw64. I confirmed it is working in Visual Studio 2010 with a 32-bit and a 64-bit compile. I will provide a sample later if necessary.

The working 32-bit version:
Using built-in specs.
Target: i686-w64-mingw32
Configured with: ../gcc44-svn/configure --target=i686-w64-mingw32 --host=i686-w64-mingw32 --disable-multilib --disable-nls --prefix=/mingw64-w32 --with-sysroot=/mingw64-w32 --with-gmp=/mingw64-w32 --with-mpfr=/mingw64-w32 --enable-languages=c,c++
Thread model: win32
gcc version 4.4.3 20091223 (prerelease) r155431 (GCC)

The 64-bit version in question:
Using built-in specs.
Target: x86_64-w64-mingw32
Configured with: ../gcc44-svn/configure --target=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --disable-multilib --disable-nls --prefix=/mingw64 --with-sysroot=/mingw64 --with-gmp=/mingw64 --with-mpfr=/mingw64 --enable-languages=c,c++
Thread model: win32
gcc version 4.4.3 20091223 (prerelease) r155431 (GCC)

These are actually the personal compiles from sezero offered by the mingw64 page.

Discussion

  • Kai Tietz

    Kai Tietz - 2010-05-21

    Hello,

    The function SetUnhandledExceptionFilter is getting overriden by newer msvcrt runtimes. There can be found some interesting articles by using a search-engine.
    The issue is, that gcc doesn't have the SEH feature for x64 (the x86 is quite different here), which is necessary for having the support of user-mode exception-filters.
    So for this you have to wait until gcc is able to generate for x64 SEH unwind-information, then you will see the same behavior as for VC.

    Regards,
    Kai

     
  • Kai Tietz

    Kai Tietz - 2010-05-21
    • status: open --> open-postponed
     
  • Ivan Maidanski

    Ivan Maidanski - 2010-11-25

    Hi!

    BoehmGC uses SetUnhandledExceptionFilter() in the incremental mode (e.g., compile GC v7.2a4 test.c using the following command line: gcc -DALL_INTERIOR_POINTERS -DGC_PREFER_MPROTECT_VDB -I.\include -s tests\test.c *.c -luser32).

    As a test case, the following could be used:

    #include <setjmp.h>
    #include <stdio.h>
    #include <windows.h>

    int *ptr = NULL;
    jmp_buf buf;

    LONG WINAPI handler(struct _EXCEPTION_POINTERS *exc_info)
    {
    longjmp(buf,1);
    }

    int main(void)
    {
    SetUnhandledExceptionFilter(handler);
    if (!setjmp(buf)) {
    *ptr = 0;
    printf("FAILED\n");
    } else {
    printf("PASSED\n");
    }
    return 0;
    }

     
  • Ivan Maidanski

    Ivan Maidanski - 2010-11-25

    I wonder: is there a macro that indicates whether the compiler is able to generate for x64 SEH unwind-information.

     
  • Kai Tietz

    Kai Tietz - 2010-11-25

    Yes, for 4.6 (which is actual the first version providing for x64 SEH frame unwind-information) there is __SEH__ defined. For an classical C exception handler example you can take a look into our crtexe.c file.

    Kai

     
  • Kai Tietz

    Kai Tietz - 2011-12-16
    • status: open-postponed --> closed-fixed
     
  • Kai Tietz

    Kai Tietz - 2011-12-16

    Issue is fixed for gcc 4.6 and newer compiler version together with trunk, 2.x, and even for 1.0 (IIRC). So close that bug as fixed.

     

Log in to post a comment.

MongoDB Logo MongoDB