-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crashing tests on Windows x64 #15709
Comments
Oops, apparently looked up the wrong error codes: FFFFFFFFC0000028 is STATUS_BAD_STACK and FFFFFFFFC00000FF is STATUS_BAD_FUNCTION_TABLE. Makes more sense. Note that locally I can only reproduce the crashes of Zend\tests\gh9407.phpt and tests\lang\bug45392.phpt, and both fail with STATUS_BAD_STACK, but only with tracing JIT enabled. gh9407.phpt fails on the |
#14919 (comment) seems to be related. PS: indeed, the tests are only failing when built with Visual Studio 2022 on x64 (but not on x86, and not when built with Visual Studio 2019). There might be an issue with vs17, or maybe just more thorough checking. |
This is a stop-gap measure for phpGH-15709 to keep CI green.
Lol. That sounds like it would be a problem. |
This is a stop-gap measure for GH-15709 to keep CI green.
If/when this issue is fixed 6d59620 should be reverted. |
Zend/tests/gh16508.phpt has the same issue ( |
This is a stop-gap measure for GH-15709 to keep CI green.
This is a stop-gap measure for GH-15709 to keep CI green. Sorry, xfailed the wrong test case previously.
I've experimented with this locally, focusing on the Zend/tests/gh9407.phpt, since I can reproduce the
PS: the issue apparently does not occur if |
Note that adding --repeat 2 and improving the JIT flags as per #12406 also creates a number of additional issues: https://github.com/danog/php-src/actions/runs/11869776299/job/33080469494#step:6:470 |
These look related to php#15709, but apparently only fail with ASan instrumentation. Let's xfail these for now.
@cmb69 you already made an excellent investigation. The problems occurs when PHP calls This works fine on 32-bit Windows because it doesn't use SEH. Actually, I'm very surprised that SEH is used for There are few ways to fix this.
Could you please do additional investigation regarding (3). May be this would help to understand more details. |
Thanks @dstogov for looking into this!
I'm afraid that will lead nowhere, since this is nowadays apparently a compiler instrinsic. We could roll our own
Ah indeed there might be something wrong per se. Running Zend/tests/gh9407.phpt with current master gives backtrace
The disassemblies around the relevant addresses (note that I've build with libcapstone, but I don't think that helps currently for MSVC). If you need more context, I can provide that. 00000203E6A15070
0000100008000D11
I do not understand that backtrace. How could code at
I'm pretty sure that we need to use |
Apparently, that backtrace can't make sense since frame information is missing for the debugger.
I made the following setjmp() experiment
So apparently, |
Modification of I see JIT-ed code modifies V8 and HotSpot use |
A quick question PHP-8.3 and below are not affected or just weren't tested with the new MSVC? |
That's apparently only an issue with the new MSVC (vs17). I found no issues when building PHP-8.4/master with vs16, IIRC. Switching back to vs16 would likely solve this issue for now, but we would probably need to rebuilt everything (dependencies and extensions). |
Did you saw the same problem in PHP-8.3 built with vs17? |
At least Zend\tests\gh9407.php passes on PHP-8.3 build with vs17. backtrace (on a breakpoint)
Disassembly around 0000100008000cdb
|
Hi @here, I opened #16449 and @cmb69 redirected me to this issue. @dstogov
I've been building php with vs17 since 8.0.8 (so all 8.3x) and I've never had any opcache JIT issue with this configuration
@cmb69
I updated my installation with this build and now I don't have 500 error anymore with
|
So, may be it's possible to fix this improving the code generator (avoid %rsp modification). @nono303 thanks for the feedback. It confirms my guess about degradation caused by new JIT back-end. |
I'm not sure that avoiding %rsp modification is even necessary. From my limited knowledge, I looks like JIT IT doesn't reserve enough stack space (old JIT decreases %rsp by 58h, while JIT IR only decreases by 48h, although several registers are pushed additionally). old JIT vs JIT IR--- C:/php-sdk/phpdev/vs17/x64/JIT IR.txt Fri Dec 6 11:33:24 2024
+++ C:/php-sdk/phpdev/vs17/x64/old JIT.txt Fri Dec 6 11:33:11 2024
@@ -1,24 +1,37 @@
-JIT IR
+old JIT
-0000100008000C9E add byte ptr [rax],al
-0000100008000CA0 sub rsp,58h
-0000100008000CA4 mov qword ptr [rsp+48h],r14
-0000100008000CA9 mov qword ptr [rsp+50h],r15
-0000100008000CAE mov r14,rcx
-0000100008000CB1 mov rax,qword ptr gs:[58h]
-0000100008000CBA mov rax,qword ptr [rax+40h]
-0000100008000CBE mov rax,qword ptr [rax+8]
-0000100008000CC2 mov dword ptr [rax+2948h],2
-0000100008000CCC mov rcx,r14
-0000100008000CCF mov rax,offset ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER (07FFB60BCE160h)
-0000100008000CD9 call rax
-0000100008000CDB mov rcx,qword ptr gs:[58h]
-0000100008000CE4 mov rcx,qword ptr [rcx+40h]
-0000100008000CE8 mov rcx,qword ptr [rcx+8]
-0000100008000CEC cmp qword ptr [rcx+2B50h],0
-0000100008000CF4 jne 00001000080001D0
-0000100008000CFA mov r14,qword ptr [rsp+48h]
-0000100008000CFF mov r15,qword ptr [rsp+50h]
-0000100008000D04 add rsp,58h
-0000100008000D08 mov rax,2
-0000100008000D0F ret
+0000100008000CD0 push rbx
+0000100008000CD1 push rbp
+0000100008000CD2 push rsi
+0000100008000CD3 push rdi
+0000100008000CD4 push r12
+0000100008000CD6 push r13
+0000100008000CD8 push r14
+0000100008000CDA push r15
+0000100008000CDC sub rsp,28h
+0000100008000CE0 mov r14,rcx
+0000100008000CE3 mov rax,qword ptr gs:[58h]
+0000100008000CEC mov rax,qword ptr [rax+38h]
+0000100008000CF0 mov rax,qword ptr [rax+8]
+0000100008000CF4 mov dword ptr [rax+29D8h],2
+0000100008000CFE sub rsp,20h
+0000100008000D02 mov rcx,r14
+0000100008000D05 mov rax,offset ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER (07FFB71524B60h)
+0000100008000D0F call rax
+0000100008000D11 add rsp,20h
+0000100008000D15 mov rax,qword ptr gs:[58h]
+0000100008000D1E mov rax,qword ptr [rax+38h]
+0000100008000D22 mov rax,qword ptr [rax+8]
+0000100008000D26 cmp qword ptr [rax+2C28h],0
+0000100008000D2E jne 0000100008000110
+0000100008000D34 mov eax,2
+0000100008000D39 add rsp,28h
+0000100008000D3D pop r15
+0000100008000D3F pop r14
+0000100008000D41 pop r13
+0000100008000D43 pop r12
+0000100008000D45 pop rdi
+0000100008000D46 pop rsi
+0000100008000D47 pop rbp
+0000100008000D48 pop rbx
+0000100008000D49 ret
Ah, thanks! Adding this to |
I finally configured windows environment and reproduced the failure with Release_TS build (Debug_TS works fine despite of the same generated code). If I make a quick hack removing %rsp modification after the prologue, Release_TS starts work. I found note about this restriction at https://codemachine.com/articles/x64_deep_dive.html ("Since push and pop instructions alter the stack pointer, X64 functions restrict push and pop instructions to the function prolog and epilog respectively. The fact that the stack pointer does not change at all between the prolog and the epilog is a characteristic feature of X64 functions, as shown in Figure 3"). To understand this better I would trace vcruntime... Where can I find CRT sources? |
The relevant difference is the optimization level ( diff win32/build/confutils.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/win32/build/confutils.js b/win32/build/confutils.js
index e847417bc7..6e7b6db031 100644
--- a/win32/build/confutils.js
+++ b/win32/build/confutils.js
@@ -3446,7 +3446,7 @@ function toolset_setup_build_mode()
ADD_FLAG("CFLAGS", "/Od /D NDebug /D NDEBUG /D ZEND_WIN32_NEVER_INLINE /D ZEND_DEBUG=0");
} else {
// Equivalent to Release_TSInline build -> best optimization
- ADD_FLAG("CFLAGS", "/Ox /D NDebug /D NDEBUG /GF /D ZEND_DEBUG=0");
+ ADD_FLAG("CFLAGS", "/Od /D NDebug /D NDEBUG /GF /D ZEND_DEBUG=0");
}
// if you have VS.Net /GS hardens the binary against buffer overruns |
@cmb69
Fyi, I build with @dstogov
diff --git "a/win32/build/confutils.js" "b/win32/build/confutils.js"
index 1a4ddbffaa..87bc57f6a2 100644
--- "a/win32/build/confutils.js"
+++ "b/win32/build/confutils.js"
@@ -3442,7 +3442,7 @@ function toolset_setup_build_mode()
// Generate external debug files when --enable-debug-pack is specified
if (PHP_DEBUG_PACK == "yes") {
ADD_FLAG("CFLAGS", "/Zi");
- ADD_FLAG("LDFLAGS", "/incremental:no /debug /opt:ref,icf");
+ ADD_FLAG("LDFLAGS", "/incremental:no /safeseh:no /debug /opt:ref,icf");
}
ADD_FLAG("CFLAGS", "/LD /MD");
if (PHP_SANITIZER == "yes" && CLANG_TOOLSET) {
|
These look related to php#15709, but apparently only fail with ASan instrumentation. Let's xfail these for now.
Description
As of 4dc7795, a couple of tests are crashing. (Note that the issues have no introduced by this commit, but are merely visible now.)
4 of these test fail with status code FFFFFFFFC00000FF, which is ERROR_EA_LIST_INCONSISTENT, while one fails with FFFFFFFFC0000028, which is ERROR_OUT_OF_PAPER (these errors don't make much sense, but the German translation of ERROR_OUT_OF_PAPER even less: "Der Drucker ist aus Papier.")
Anyhow, this appears to be a tracing JIT issue.
PHP Version
master
Operating System
Windows
The text was updated successfully, but these errors were encountered: