This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/9539: builtin [long/set]jmp not working properly with Windows signals
- From: obry at gnat dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 2 Feb 2003 18:24:09 -0000
- Subject: c/9539: builtin [long/set]jmp not working properly with Windows signals
- Reply-to: obry at gnat dot com
>Number: 9539
>Category: c
>Synopsis: builtin [long/set]jmp not working properly with Windows signals
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Feb 02 18:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: obry@gnat.com
>Release: GCC 2.8.1 and GCC 3.2.2
>Organization:
>Environment:
Windows NT/XP with:
- MingW C compiler 3.2
- C compiler coming with GNAT 3.x (GCC 2.8.1)
- GCC 3.2.2
>Description:
A signal handler is not working properly the second time it is called. Look at the following program.
We install an exception handler. This handler will be triggered each time a signal is raised. In run() we explicitely read memory at address 0x0. This raise an exception access violation. This signal is captured the first time. The second time the program freeze somewhere in OS code...
Maybe there is some specific code to call before leaving the exception handler?
>How-To-Repeat:
Compile the following program and run it:
$ gcc -o code code.c
$ ./code
/* This program run fine if it uses the standard [set/long]jmp and freeze at
the second signal if it uses the builtin version.
*/
#include <stdio.h>
#include <windows.h>
#include <setjmp.h>
/* Just uncomment the following line to reproduce the bug
If commented out, we use the OS [set/long]jmp and the program works as
expected.
*/
#define BUILTIN
#ifdef BUILTIN
#define setjmp __builtin_setjmp
#define longjmp __builtin_longjmp
#else
#endif
static jmp_buf jb;
void
run (void)
{
int *addr = 0x0;
int a;
{
setjmp (jb);
printf ("let's go\n"); fflush (stdout);
/* let's raise an exception access violation */
a = *addr;
}
}
static LONG
error_handler (info)
PEXCEPTION_POINTERS info;
{
printf ("Error Handler\n"); fflush (stdout);
longjmp (jb, 1);
return EXCEPTION_CONTINUE_EXECUTION;
}
int
main (void)
{
int *addr = 0x0;
int a;
printf ("Install error handler\n"); fflush (stdout);
SetUnhandledExceptionFilter (error_handler);
run();
}
>Fix:
No fix to propose.
I'd like to hear what you think about this.
>Release-Note:
>Audit-Trail:
>Unformatted: