-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fibers are broken on alpine x86 with clang #10398
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
Comments
May be related: #9566 |
Thank you for filing issue. Sadly I have no idea how to tackle it |
FYI I'm building only PHP 8.2 with clang, |
I'm taking a brief look at this, it's a segfault in zend_fibers.c:350: Line 350 in 3ed5264
|
The problem seems to be in how the pointers (that are in the argument's struct) are passed from the assembly to the function. |
The following patch fixes it for me. I guess more platforms than just Alpine are actually affected by this: diff --git a/Zend/asm/make_i386_sysv_elf_gas.S b/Zend/asm/make_i386_sysv_elf_gas.S
index b76de260..5568f57b 100644
--- a/Zend/asm/make_i386_sysv_elf_gas.S
+++ b/Zend/asm/make_i386_sysv_elf_gas.S
@@ -82,8 +82,8 @@ make_fcontext:
trampoline:
/* move transport_t for entering context-function */
- movl %edi, (%esp)
- movl %esi, 0x4(%esp)
+ pushl %esi
+ pushl %edi
pushl %ebp
/* jump to context-function */
jmp *%ebx
Can someone else please also verify if this fixes it for them? Thanks :) Note: idk why the stack overwriting was used instead of pushing, I guess to save stack space? If that's the case we can do that too but the solution becomes a little more complicated. |
I don't have a Linux 32-bit install handy, and I want to check whether it breaks other platforms or not. So I'm going to create a draft PR so that CI can run through this. EDIT: oh also, I guess if this fix works then we can get rid of the fiber tests in that ignorelist you mentioned here: #9735 (comment) ? |
The arguments were passed incorrectly. This uses the regular approach to pass arguments on the SYSV 32-bit ABI.
Fixes phpGH-10398 The stack was misaligned upon entering the trampoline function [1], this causes a CPU trap when the SSE instruction is executed to copy data from the stack. This was fixed upstream [2]. This commit syncs all upstream changes from the boost/context assembly files to our copy. [1] php#10407 (comment) [2] boostorg/context#219
Description
Found while looking at #9735 (comment)
Most fibers tests fail when building with clang on alpine x86 in non-debug.
This Dockerfile allows to reproduce the issue:
Also happens in an alpine VM:
Tests pass when building with gcc, or with -O0.
PHP Version
8.1 f673449
Operating System
Alpine 3.17.1 x86
The text was updated successfully, but these errors were encountered: