You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We tried to use tcmalloc (tcmalloc_minimal) from gperftools v2.10 together with PHP. Unfortunately PHP-FPM crashes right at the beginning in mysqli.so.
We tried both variants: a) adding LD_PRELOAD=/opt/lamprt/lib/libtcmalloc_minimal.so and b) adding libtcmalloc_minimal at compile time with -ltcmalloc_minimal without LD_PRELOAD. Both variants cause a crash. Below is the stack trace of variant a).
This is a duplicate of #10670 (see that issue for more details).
Injecting custom allocators by overriding libc's allocator with LD_PRELOAD or linking flags is not supported. This is because PHP uses RTLD_DEEPLINK to link its dependent libraries.
RTLD_DEEPLINK makes sure that a library will always prefer its local symbols over the global ones, hence not all places that call malloc() and free() will use tcmalloc. You can see this in the backtrace of your post: the freeing happened with libc's free() while the allocation happened with tcmalloc. This doesn't work and therefore it crashes.
These custom allocators used to have a workaround for applications using RTLD_DEEPLINK, but glibc removed support for that fairly recently.
It's not possible to disable RTLD_DEEPLINK because there are libraries PHP depends on where some symbols may conflict with symbols from other libraries. If you are sure this isn't the case for your setup you can search for RTLD_DEEPLINK in PHP's source code and replace it with the constant 0.
Description
We tried to use tcmalloc (tcmalloc_minimal) from gperftools v2.10 together with PHP. Unfortunately PHP-FPM crashes right at the beginning in mysqli.so.
We tried both variants: a) adding
LD_PRELOAD=/opt/lamprt/lib/libtcmalloc_minimal.so
and b) addinglibtcmalloc_minimal
at compile time with-ltcmalloc_minimal
withoutLD_PRELOAD
. Both variants cause a crash. Below is the stack trace of variant a).complete core dump from systemd: core dump.log
PHP Version
PHP 8.2.7
Operating System
No response
The text was updated successfully, but these errors were encountered: