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);

        }

}

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to