-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix PHP 8.5+ ZTS segfault on CentOS 7 by disabling IFUNC resolvers #20027
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
Fix PHP 8.5+ ZTS segfault on CentOS 7 by disabling IFUNC resolvers #20027
Conversation
CentOS 7's glibc lacks __builtin_cpu_init() support, causing IFUNC resolvers to crash during dynamic linking when detecting AVX2 support. Disable IFUNC and use runtime function pointer initialization instead.
Looking good, but I do not know if it is requested to be "consistent" with FreeBSD check style, e.g. getconf GNU_LIBC_VERSION | awk '{print 2ドル}' | cut -d. -f2
. cc @iluuu1994
CentOS 7 is 11 years old and EOL for >1 year
https://blog.centos.org/2023/04/end-dates-are-coming-for-centos-stream-8-and-centos-linux-7/
There are so much things outdated there, a lot of PHP dependencies are no longer satisfied
I don't see the benefit of maintaining for dead targets
I don't see the benefit of maintaining for dead targets
Me neither but it is an "easy" fix and there are still folks using Linux with outdated glibc versions so I though: why not.
An alternative could be to document the workaround we are using currently and that is just adding ax_cv_have_func_attribute_ifunc=no
to the arguments for ./configure
for PHP 8.5 ZTS on old glibc versions:
$ ./configure ax_cv_have_func_attribute_ifunc=no --enable-zts --other-flags
IDK where to document this, most likely just having this comment posted here might already be enough for folks to find it 😉
I remember Girgias and I had been discussing to level up the minimum os versions for the next major release. It was centos 8, solaris 10 ... for the next 8.6 I believe.
Uh oh!
There was an error while loading. Please reload this page.
CentOS 7's glibc (
2.17
)__builtin_cpu_init()
causesIFUNC
resolvers to crash during dynamic linking when detecting AVX2 support on a ZTS build on Amd64 hardware.This PR disables
IFUNC
on Amd64 hardware when a glibc version <=2.17
is detected.The stacktrace for the segfault looks like this when executing a freshly build
./sapi/cli/php
:This is even before PHP's
main()
function is called.Arm64 is not affected because
zend_cpu_supports_avx2(void)
has an early return for Arm64:php-src/Zend/zend_cpuinfo.h
Lines 200 to 210 in 52e1c9f
Why NTS is not affected: I have no idea 🫤
Also: why this is not a problem on PHP 8.4 ZTS Amd64: no idea either