Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
realFlowControl wants to merge 1 commit into php:PHP-8.5
base: PHP-8.5
Choose a base branch
Loading
from realFlowControl:florian/disable-ifunc-on-glibc-2.17

Conversation

Copy link
Contributor

@realFlowControl realFlowControl commented Oct 1, 2025
edited
Loading

CentOS 7's glibc (2.17) __builtin_cpu_init() causes IFUNC 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:

#0 0x0000555555972b5a in resolve_wchar_utf16be ()
#1 0x00007ffff7de6e6f in _dl_relocate_object () from /lib64/ld-linux-x86-64.so.2
#2 0x00007ffff7ddf99a in dl_main () from /lib64/ld-linux-x86-64.so.2
#3 0x00007ffff7df300e in _dl_sysdep_start () from /lib64/ld-linux-x86-64.so.2
#4 0x00007ffff7ddcbd1 in _dl_start () from /lib64/ld-linux-x86-64.so.2
#5 0x00007ffff7ddc148 in _start () from /lib64/ld-linux-x86-64.so.2
#6 0x0000000000000003 in ?? ()
#7 0x00007fffffffe287 in ?? ()
#8 0x00007fffffffe29a in ?? ()
#9 0x00007fffffffe29d in ?? ()
#10 0x0000000000000000 in ?? ()

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

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_avx2(void) {
#ifdef __aarch64__
return 0;
#else
#ifdef PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("avx2");
#endif
}

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

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.
@realFlowControl realFlowControl changed the base branch from master to PHP-8.5 October 1, 2025 12:13
@realFlowControl realFlowControl marked this pull request as ready for review October 1, 2025 12:23
Copy link
Member

devnexen commented Oct 1, 2025
edited
Loading

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

Copy link
Member

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

Copy link
Contributor Author

realFlowControl commented Oct 2, 2025
edited
Loading

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 😉

devnexen reacted with thumbs up emoji

Copy link
Member

devnexen commented Oct 2, 2025

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.

realFlowControl reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /