tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] Windows x86_64 BUG, SIGSEV is not correctly handled by in


From: Christian Jullien
Subject: [Tinycc-devel] Windows x86_64 BUG, SIGSEV is not correctly handled by installed signal handler.
Date: Mon, 8 Apr 2019 16:57:49 +0200

Using mob, the code below works on Windows 10 with PE (i386) but hangs on PE+ (x86_64)

 

handler function is not entered with x86_64.

 

Expected behavior with –m32:

 

c:\tmp>tcc -m32 signal.c && signal

Waiting for SIGSEGV

Got signal 11!! Want to exit? [y/n] y

Exiting from handler...

 

c:\tmp>tcc -m32 signal.c && signal

Waiting for SIGSEGV

Got signal 11!! Want to exit? [y/n] n

Reinstall handler...

Exiting normally

 

BUG with –m64

 

c:\tmp>tcc -m64 signal.c && signal

Waiting for SIGSEGV  <<= program terminates after this print!!

 

c:\tmp>

/// signal.c

 

#include  <stdio.h>

#include  <signal.h>

#include  <stdlib.h>

#include  <setjmp.h>

 

jmp_buf jmp;

 

void handler(int);

 

int

main(void) {

     signal(SIGSEGV, handler);

     (void)printf("Waiting for SIGSEGV\n");

     if (setjmp(jmp) == 0) {

             char *p = NULL;

             *p = 'A';  // force SIGSEGV

     } else {

             (void)printf("Exiting normally\n");

     }

 

     return 0;

}

 

void

handler(int sig) {

        int c = 'y';

 

        signal(sig, SIG_IGN);  // <= Same issue with or w.o. this line

        fprintf(stderr, "Got signal %d!! Want to exit? [y/n] ", sig);

        fflush(stderr);

        c = fgetc(stdin);

        if (c == 'y' || c == 'Y') {

                (void)printf("Exiting from handler...\n");

                exit(0);

        } else {

                (void)printf("Reinstall handler...\n");

                signal(SIGINT, handler);

                longjmp(jmp, 1);

        }

}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]