[php-src] Issue #12442: PHP intl segfault (static build by musl gcc/g++ built with --enable-default-pie)

From: Date: Sun, 15 Oct 2023 12:51:10 +0000
Subject: [php-src] Issue #12442: PHP intl segfault (static build by musl gcc/g++ built with --enable-default-pie)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245577@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12442 Author: DubbleClick ### Description The following code: ```php php --ri "intl" ``` Resulted in this output: ```console [root@alma static-php-cli]# ./buildroot/bin/php --ri "intl" intl Internationalization support => enabled ICU version => 73.2 ICU Data version => 73.2 Segmentation fault (core dumped) [root@alma static-php-cli]# gdb -q ./buildroot/bin/php Reading symbols from ./buildroot/bin/php... (gdb) run --ri "intl" Starting program: /opt/static-php-cli/buildroot/bin/php --ri "intl" intl Internationalization support => enabled ICU version => 73.2 ICU Data version => 73.2 Program received signal SIGSEGV, Segmentation fault. 0x00007ffff5db631b in __do_cleanup_push () (gdb) bt #0 0x00007ffff5db631b in __do_cleanup_push () #1 0x00007ffff5daba93 in __pthread_once_full () #2 0x00007ffff5e68835 in ?? () #3 0x00007ffff5daba08 in pthread_mutex_unlock () #4 0x00007ffff7f7d878 in umtx_init::{lambda()#1}::operator()() const::storage () #5 0x000667a0e8022617 in ?? () #6 0x00007ffff7f7b360 in MAP_SYSTEM_ZONES () #7 0x00007fffffffcca0 in ?? () #8 0x0000000000000000 in ?? () (gdb) quit A debugging session is active. Inferior 1 [process 1337827] will be killed. Quit anyway? (y or n) y ``` But I expected this output instead: ``` [root@alma static-php-cli]# ./buildroot/bin/php --ri "intl" intl Internationalization support => enabled ICU version => 73.2 ICU Data version => 73.2 ICU TZData version => 2023c ICU Unicode version => 15.0 Directive => Local Value => Master Value intl.default_locale => no value => no value intl.error_level => 0 => 0 intl.use_exceptions => Off => Off ``` This happens with all versions of gcc >9. It happens with all version of php >= 8.0 and all versions of the icu library >= 71.1. Likewise, with all version of linux-headers >= 4. I didn't test lower versions. **Building musl-cross-make without --enable-default-pie fixes this issue!** To reproduce this, you may use [static-php-cli](https://github.com/DubbleClick/static-php-cli/tree/cplusplus) with ./bin/spc build intl --build-cli --no-strip. It downloads a version of musl-cross-make that compiled gcc with --enable-default-pie hosted at https://musl.cc To reproduce the fix, clone https://git.zv.io/toolchains/musl-cross-make.git, create a config.mak in the directory ```mak FLAG = -g0 -O2 -Wno-error -fPIE COMMON_CONFIG += CFLAGS="${FLAG}" CXXFLAGS="${FLAG}" LDFLAGS="-s" BINUTILS_CONFIG += --enable-gold=yes GCC_CONFIG += --enable-static-pie --disable-cet #--enable-default-pie --disable-cet CONFIG_SUB_REV = 888c8e3d5f7b GCC_VER = 11.4.0 BINUTILS_VER = 2.40 MUSL_VER = 1.2.4 GMP_VER = 6.2.1 MPC_VER = 1.2.1 MPFR_VER = 4.1.0 LINUX_VER = 6.1.36 ``` and build with make install -j TARGET=x86_64-linux-musl. The resulting c/c++ toolchain can now be used to compile php with the intl extension - but it won't support position independent executables generated using libphp.a. The gcc/g++ built on musl-libc based distros such as alpine appears to be built with --enable-default-pie, but do not show the same problem. intl works. For what it's worth, the following extensions compiled statically all work, except for intl: ./bin/spc build mbstring,mbregex,apcu,bcmath,calendar,ctype,curl,dom,exif,fileinfo,filter,gd,iconv,intl,ldap,xml,xmlreader,xmlwriter,simplexml,mysqli,mysqlnd,openssl,posix,pcntl,pdo_mysql,pdo_pgsql,pdo,pgsql,session,sysvsem,sodium,tokenizer,zlib,zip,opcache,snappy,imagick --with-libs=libpam,freetype,libavif,libjpeg,libwebp --build-embed --enable-zts ### PHP Version * ### Operating System Glibc based UNIX systems

« previous php.bugs (#245577) next »