tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] setjmp/longjmp with in-memory compilation on Windows with


From: brad
Subject: [Tinycc-devel] setjmp/longjmp with in-memory compilation on Windows with CFG
Date: Wed, 17 Jan 2024 08:25:44 +0000

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




reply via email to

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