-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix GH-10398: Fibers are broken on alpine x86 with clang #10407
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
Conversation
Note that the upstream project for those assembly codes come from here |
Unless I'm reading over it, it seems that the trampoline part isn't in the original? |
Nvm I found it. |
Just to be clear: Edit: I originally wrote addl above instead of subl, mistake when typing over the code |
Your alternative solution has my personal preference, but nevermind you can perfectly defend your case upstream in due time, I have only contributed once a while ago but they re pretty nice as far as I remember. |
@nielsdos Could you please submit this fix upstream to boost/context first? I prefer to get their insight and approval before applying changes to the bundled assembly files here. |
@trowski I spent some more time figuring out this issue, and it finally clicked. The patch in this PR only fixes the issue by accident. There is no overwrite issue, it's a stack alignment issue... The fix is simple, this code: php-src/Zend/asm/make_i386_sysv_elf_gas.S Line 44 in 90b0e77
Should actually become:
This works because 0x30 is a multiple of 16 and the stack was already 16-byte aligned at this point. Other assembly files for i386 may require a modification as well. I'll make PR to the boost context repo soon-ish. |
My fix got merged in the boost/context repo. |
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
I've gone for strategy (2) and updated all assembly files. |
Merging in all the changes from boost/context has brought in the the changes made for shadow stack support in #9283, but this is fine I think because the flag isn't set in 8.1 and 8.2, so those sections are skipped anyway. There's also changes adding a |
I don't see an option for stack protection in the configure script. I think that the stack protector is off in standard GCC/Clang, but some distros turn it on by default (and also the fortify options iirc). But yeah that can probably go in a separate PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Let's merge this then and look at what needs to be done for stack protection and defining BOOST_CONTEXT_TLS_STACK_PROTECTOR
in another PR.
FYI I've applied PR as patch and x86-CI no loner reports failed fiber tests https://gitlab.alpinelinux.org/alpine/aports/-/jobs/965476 |
btw uncommented 3 tests that failed on ppc64le https://gitlab.alpinelinux.org/alpine/aports/-/jobs/965496
|
bit they are fails
|
Yeah I only spent time debugging and fixing x86, I might look at the PPC cases sometime later, but that's unrelated to this PR though. |
Thank you! |
My pleasure :) @devnexen Thanks for merging. This also fixes GH-9357 as confirmed here: #10407 (comment). Could you please close that issue too? :) |
Follow-up for fibers on ppc64le #10512 |
Fixes GH-10398, maybe fixes GH-9357 too.