zherczeg / sljit

Platform independent low-level JIT compiler
Other
843 stars 74 forks source link

Test failed on Windows11 #231

Closed jwhere closed 9 months ago

jwhere commented 9 months ago

The test code fails on Windows 11 after the commit https://github.com/zherczeg/sljit/commit/2cfed9ce43e0ddc1cfe3456ef020da5c82199272

On the x86 build, a StackOverflow occurs at sljitTest.c:1631 and on the x64 build, an AccessViolation occurs at sljitTest.c:1327

zherczeg commented 9 months ago

Why did you close this bug?

jwhere commented 9 months ago

because even before the commit https://github.com/zherczeg/sljit/commit/2cfed9ce43e0ddc1cfe3456ef020da5c82199272, multiple tests and asserts(ex: https://github.com/zherczeg/sljit/blob/master/test_src/sljitTest.c#L5358) were failing on Windows 11

zherczeg commented 9 months ago

I remember something like this. The test system uses a custom executable allocator to test corner cases, and SLJIT_HAVE_CONFIG_PRE=1 is missing from your config.

See https://github.com/zherczeg/sljit/blob/master/GNUmakefile#L80

jwhere commented 9 months ago

More information about segfaults:

Visual Studio 2022 (MSVC) https://github.com/zherczeg/sljit/assets/30134273/f077be63-e599-4145-aeec-87089a429eca

msys2 (mingw64) msys

zherczeg commented 9 months ago

I can reproduce the 64 bit issue. The following code needs to be inserted to copy the rex.b to rex.r: sljitNativeX86_64.c:411 code_ptr[-3 - SSIZE_OF(s32)] = U8(REX_W | ((code_ptr[-3 - SSIZE_OF(s32)] & 0x1) << 2)); I don't see any issue with 32 bit.

jwhere commented 9 months ago

msys32

You are right. In the msys2 mingw32 environment, all tests passed. However, in msvc, a stack overflow occurs during the test20 in the 32-bit environment. 👀

zherczeg commented 9 months ago

I used msvc / win11, and 32 bit worked here. However, test20 uses 1MB function stack for testing, which might be too much depending on your system configuration. I think you can increase it somewhere in msvc.

jwhere commented 9 months ago

msvc32

Increasing the stack size to 10mb seems to work well 😊

zherczeg commented 9 months ago

2MB should be enough. Thank you for reporting this issue. I will commit a fix for the bug.