Hi All,

I'm trying to use setjmp/longjmp in code that needs to be compiled to in-memory.

On Windows 11 (and presumably Windows 10) when you have Control Flow Guard enabled, it crashes on calling longjmp.

If compiled to .exe it works fine. When Control Flow Guard is disabled (Control Panel ... -> ... Exploit Protection) is works fine.

I've read up a little on this and it seems like it's an exception being thrown in kernel, by a call to check the call target from the CRT. I've also read that the call target should be allowed if the target address' page has been marked executable - so I think this should work, but it's definitely not.

Sample program test.c below that fails in the longjmp call when running `tcc -run test.c`

Any ideas?

Brad

#include <stdio.h>
#include <setjmp.h>
jmp_buf jmpbuf;
void my_function()
{
    longjmp(jmpbuf, 1);
}
int main()
{
    if (setjmp(jmpbuf) == 0)
    {
        printf("A\n");
        my_function();
        printf("B\n");
    }
    printf("C\n");
    return 0;
}
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to