From ca09f4dba463034a1c312426630ed1672e7d90d0 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Tue, 1 Jul 2025 15:17:40 -0500 Subject: [PATCH 01/59] PHP-8.1 is now for PHP 8.1.34-dev --- NEWS | 4 ++++ Zend/zend.h | 2 +- configure.ac | 2 +- main/php_version.h | 6 +++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 8c8b28fb9818..d52050e3a8e3 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +?? ??? ????, PHP 8.1.34 + + + 03 Jul 2025, PHP 8.1.33 - PGSQL: diff --git a/Zend/zend.h b/Zend/zend.h index 6562119e8363..29bb98c85fca 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -20,7 +20,7 @@ #ifndef ZEND_H #define ZEND_H -#define ZEND_VERSION "4.1.33-dev" +#define ZEND_VERSION "4.1.34-dev" #define ZEND_ENGINE_3 diff --git a/configure.ac b/configure.ac index 0f45db92ba7d..51256f6b7c17 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ dnl Basic autoconf initialization, generation of config.nice. dnl ---------------------------------------------------------------------------- AC_PREREQ([2.68]) -AC_INIT([PHP],[8.1.33-dev],[https://github.com/php/php-src/issues],[php],[https://www.php.net]) +AC_INIT([PHP],[8.1.34-dev],[https://github.com/php/php-src/issues],[php],[https://www.php.net]) AC_CONFIG_SRCDIR([main/php_version.h]) AC_CONFIG_AUX_DIR([build]) AC_PRESERVE_HELP_ORDER diff --git a/main/php_version.h b/main/php_version.h index 2aee6f19d16a..96bd615c0738 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,7 +2,7 @@ /* edit configure.ac to change version number */ #define PHP_MAJOR_VERSION 8 #define PHP_MINOR_VERSION 1 -#define PHP_RELEASE_VERSION 33 +#define PHP_RELEASE_VERSION 34 #define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "8.1.33-dev" -#define PHP_VERSION_ID 80133 +#define PHP_VERSION "8.1.34-dev" +#define PHP_VERSION_ID 80134 From b6660634b4ff951d1ca98d02381853645faa57af Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 15 Feb 2024 10:24:41 +0100 Subject: [PATCH 02/59] Disable JIT on Apple Silicon + ZTS Apple Silicon has stricter rules about rwx mmap regions. They need to be created using the MAP_JIT flag. However, the MAP_JIT seems to be incompatible with MAP_SHARED. ZTS requires MAP_SHARED so that some threads may execute code from a page while another writes/appends to it. We did not find another solution, other than completely disabling JIT for Apple Silicon + ZTS. See discussion in https://github.com/php/php-src/pull/13351. Co-authored-by: Peter Kokot Fixes GH-13400 Closes GH-13396 --- ext/opcache/config.m4 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4 index 0b923206282c..d35efbc689ed 100644 --- a/ext/opcache/config.m4 +++ b/ext/opcache/config.m4 @@ -36,6 +36,10 @@ if test "$PHP_OPCACHE" != "no"; then PHP_OPCACHE_JIT=no ;; esac + if test "$host_vendor" = "apple" && test "$host_cpu" = "aarch64" && test "$PHP_THREAD_SAFETY" = "yes"; then + AC_MSG_WARN([JIT not supported on Apple Silicon with ZTS]) + PHP_OPCACHE_JIT=no + fi fi if test "$PHP_OPCACHE_JIT" = "yes"; then From a5df26691d1b1f71b964b869510473a5d5413999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 15 Jul 2025 13:36:56 +0200 Subject: [PATCH 03/59] ext/xml: Suppress libxml deprecation for `_xmlParserCtxt.inState` (#19131) The FreeBSD build fails due to the deprecation and -Werror: 2025-07-15T00:37:20.8390774Z /home/runner/work/php-src/php-src/ext/xml/compat.c:358:38: error: 'instate' is deprecated [-Werror,-Wdeprecated-declarations] 2025-07-15T00:37:20.8392577Z 358 | if (ret == NULL || parser->parser->instate == XML_PARSER_CONTENT) { 2025-07-15T00:37:20.8393184Z | ^ 2025-07-15T00:37:20.8394006Z /usr/local/include/libxml2/libxml/parser.h:309:33: note: 'instate' has been explicitly marked deprecated here 2025-07-15T00:37:20.8394903Z 309 | xmlParserInputState instate XML_DEPRECATED_MEMBER; 2025-07-15T00:37:20.8395413Z | ^ 2025-07-15T00:37:20.8396166Z /usr/local/include/libxml2/libxml/xmlexports.h:74:50: note: expanded from macro 'XML_DEPRECATED_MEMBER' 2025-07-15T00:37:20.8397058Z 74 | #define XML_DEPRECATED_MEMBER __attribute__((deprecated)) 2025-07-15T00:37:20.8397581Z | ^ 2025-07-15T00:37:20.8425542Z 1 error generated. --- ext/xml/compat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/xml/compat.c b/ext/xml/compat.c index 7b463ebb5112..6bd69bec1961 100644 --- a/ext/xml/compat.c +++ b/ext/xml/compat.c @@ -375,7 +375,9 @@ _get_entity(void *user, const xmlChar *name) if (ret == NULL) ret = xmlGetDocEntity(parser->parser->myDoc, name); + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") if (ret == NULL || (parser->parser->instate != XML_PARSER_ENTITY_VALUE && parser->parser->instate != XML_PARSER_ATTRIBUTE_VALUE)) { + ZEND_DIAGNOSTIC_IGNORED_END if (ret == NULL || ret->etype == XML_INTERNAL_GENERAL_ENTITY || ret->etype == XML_INTERNAL_PARAMETER_ENTITY || ret->etype == XML_INTERNAL_PREDEFINED_ENTITY) { /* Predefined entities will expand unless no cdata handler is present */ if (parser->h_default && ! (ret && ret->etype == XML_INTERNAL_PREDEFINED_ENTITY && parser->h_cdata)) { From 605ee054915beff79811c2b2868888426ce16ff2 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 21 Jul 2025 23:19:48 +0200 Subject: [PATCH 04/59] Fix test conflict between chmod_variation2 and file_variation5 Both used "somelink". See https://github.com/php/php-src/actions/runs/16427526464/job/46421461376 Closes GH-19208. --- ext/standard/tests/file/chmod_variation2.phpt | 2 +- ext/standard/tests/file/file_variation5.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/standard/tests/file/chmod_variation2.phpt b/ext/standard/tests/file/chmod_variation2.phpt index e96af25ec469..c2b6c2e810a3 100644 --- a/ext/standard/tests/file/chmod_variation2.phpt +++ b/ext/standard/tests/file/chmod_variation2.phpt @@ -34,7 +34,7 @@ clearstatcache(); printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK); echo "\nchmod() on a linked file\n"; -$linkname = "somelink"; +$linkname = "somelink2"; var_dump(symlink($filepath, $linkname)); var_dump(chmod($filepath, 0777)); var_dump(chmod($linkname, 0755)); diff --git a/ext/standard/tests/file/file_variation5.phpt b/ext/standard/tests/file/file_variation5.phpt index 7f012b7d431e..65e68ab0927d 100644 --- a/ext/standard/tests/file/file_variation5.phpt +++ b/ext/standard/tests/file/file_variation5.phpt @@ -27,7 +27,7 @@ echo "\nfile() on a path containing .. with invalid directories\n"; var_dump(file("./$test_dirname/bad_dir/../../$filename")); echo "\nfile() on a linked file\n"; -$linkname = "somelink"; +$linkname = "somelink5"; var_dump(symlink($filepath, $linkname)); var_dump(file($linkname)); var_dump(unlink($linkname)); From be8819259417d63b389eb9ea6c00abd6aeb8e1c6 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Tue, 22 Jul 2025 14:30:40 +0200 Subject: [PATCH 05/59] Run FreebSD CI under 13.5 13.3 gives a 404 now. Also pulls in a 8.4 fix to include xxhash from the bundled location. Closes GH-19213. --- .github/actions/freebsd/action.yml | 2 +- ext/hash/php_hash_xxhash.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/freebsd/action.yml b/.github/actions/freebsd/action.yml index fd37e92bbe5f..17446311bb86 100644 --- a/.github/actions/freebsd/action.yml +++ b/.github/actions/freebsd/action.yml @@ -9,7 +9,7 @@ runs: - name: FreeBSD uses: vmactions/freebsd-vm@v1 with: - release: '13.3' + release: '13.5' usesh: true copyback: false # Temporarily disable sqlite, as FreeBSD ships it with disabled double quotes. We'll need to fix our tests. diff --git a/ext/hash/php_hash_xxhash.h b/ext/hash/php_hash_xxhash.h index a1e8840ce272..ace70deedb00 100644 --- a/ext/hash/php_hash_xxhash.h +++ b/ext/hash/php_hash_xxhash.h @@ -18,7 +18,7 @@ #define PHP_HASH_XXHASH_H #define XXH_INLINE_ALL 1 -#include "xxhash.h" +#include "xxhash/xxhash.h" typedef struct { XXH32_state_t s; From b63372058552fd7cae24a8684d8b2b8276b3a2fc Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Sat, 26 Jul 2025 10:03:34 +0200 Subject: [PATCH 06/59] Add unique entry point for extra tests We are adding extra (non-phpt) test suites in [1] and [2]. In order to avoid touching CI files too often (which are maintained in 8.1 and merged in upper branches), we add a single entry point to call the extra tests. The entry point can be updated in branches without synchronizing all the way from 8.1. CI files still need to be touched to install dependencies of these tests, but this should be manageable as these do not change often and are the same in every branch. Closes GH-19242. [1] https://github.com/php/php-src/pull/16987 [2] https://github.com/php/php-src/pull/18939 --- .github/actions/apt-x32/action.yml | 5 +- .github/actions/apt-x64/action.yml | 5 +- .github/actions/extra-tests/action.yml | 7 ++ .github/actions/freebsd/action.yml | 13 ++- .github/workflows/nightly.yml | 11 +++ run-extra-tests.php | 123 +++++++++++++++++++++++++ 6 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 .github/actions/extra-tests/action.yml create mode 100755 run-extra-tests.php diff --git a/.github/actions/apt-x32/action.yml b/.github/actions/apt-x32/action.yml index 879300f99274..0147b15cfcf5 100644 --- a/.github/actions/apt-x32/action.yml +++ b/.github/actions/apt-x32/action.yml @@ -6,6 +6,8 @@ runs: run: | set -x + OPCACHE_TLS_TESTS_DEPS="gcc clang lld" + export DEBIAN_FRONTEND=noninteractive dpkg --add-architecture i386 apt-get update -y | true @@ -50,4 +52,5 @@ runs: re2c \ unzip \ wget \ - zlib1g-dev:i386 + zlib1g-dev:i386 \ + $OPCACHE_TLS_TESTS_DEPS diff --git a/.github/actions/apt-x64/action.yml b/.github/actions/apt-x64/action.yml index 4e1a03dd58cc..15697ed9f2fa 100644 --- a/.github/actions/apt-x64/action.yml +++ b/.github/actions/apt-x64/action.yml @@ -6,6 +6,8 @@ runs: run: | set -x + OPCACHE_TLS_TESTS_DEPS="gcc clang lld" + sudo apt-get update sudo apt-get install \ bison \ @@ -58,4 +60,5 @@ runs: libqdbm-dev \ libjpeg-dev \ libpng-dev \ - libfreetype6-dev + libfreetype6-dev \ + $OPCACHE_TLS_TESTS_DEPS diff --git a/.github/actions/extra-tests/action.yml b/.github/actions/extra-tests/action.yml new file mode 100644 index 000000000000..053749606400 --- /dev/null +++ b/.github/actions/extra-tests/action.yml @@ -0,0 +1,7 @@ +name: Extra tests +runs: + using: composite + steps: + - shell: sh + run: | + sapi/cli/php run-extra-tests.php diff --git a/.github/actions/freebsd/action.yml b/.github/actions/freebsd/action.yml index 17446311bb86..ce133925e252 100644 --- a/.github/actions/freebsd/action.yml +++ b/.github/actions/freebsd/action.yml @@ -3,6 +3,9 @@ inputs: configurationParameters: default: '' required: false + runExtraTests: + default: false + required: false runs: using: composite steps: @@ -17,6 +20,8 @@ runs: prepare: | cd $GITHUB_WORKSPACE + OPCACHE_TLS_TESTS_DEPS="gcc" + kldload accf_http pkg install -y \ autoconf \ @@ -41,9 +46,11 @@ runs: webp \ libavif \ `#sqlite3` \ - curl + curl \ + $OPCACHE_TLS_TESTS_DEPS ./buildconf -f + CC=clang CXX=clang++ \ ./configure \ --prefix=/usr/local \ --enable-debug \ @@ -106,3 +113,7 @@ runs: --show-slow 1000 \ --set-timeout 120 \ -d zend_extension=opcache.so + + if test "${{ inputs.runExtraTests }}" = "true"; then + sapi/cli/php run-extra-tests.php + fi diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 5817c647a871..38ccb05e0992 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -85,6 +85,8 @@ jobs: with: runTestsParameters: >- --asan -x + - name: Extra tests + uses: ./.github/actions/extra-tests ALPINE: if: inputs.run_alpine name: ALPINE_X64_ASAN_UBSAN_DEBUG_ZTS @@ -134,6 +136,8 @@ jobs: --asan -x -d zend_extension=opcache.so -d opcache.enable_cli=1 + - name: Extra tests + uses: ./.github/actions/extra-tests - name: Notify Slack if: failure() uses: ./.github/actions/notify-slack @@ -266,6 +270,8 @@ jobs: ${{ matrix.run_tests_parameters }} -d zend_extension=opcache.so -d opcache.enable_cli=1 + - name: Extra tests + uses: ./.github/actions/extra-tests - name: Verify generated files are up to date uses: ./.github/actions/verify-generated-files - name: Notify Slack @@ -355,6 +361,8 @@ jobs: ${{ matrix.run_tests_parameters }} -d zend_extension=opcache.so -d opcache.enable_cli=1 + - name: Extra tests + uses: ./.github/actions/extra-tests - name: Notify Slack if: failure() uses: ./.github/actions/notify-slack @@ -414,6 +422,8 @@ jobs: runTestsParameters: >- -d zend_extension=opcache.so -d opcache.enable_cli=1 + - name: Extra tests + uses: ./.github/actions/extra-tests - name: Verify generated files are up to date uses: ./.github/actions/verify-generated-files - name: Notify Slack @@ -1076,3 +1086,4 @@ jobs: with: configurationParameters: >- --${{ matrix.zts && 'enable' || 'disable' }}-zts + runExtraTests: true diff --git a/run-extra-tests.php b/run-extra-tests.php new file mode 100755 index 000000000000..a299addf4044 --- /dev/null +++ b/run-extra-tests.php @@ -0,0 +1,123 @@ +#!/usr/bin/env php +os}\n"; + echo "CPU Arch: {$environment->cpuArch}\n"; + echo "ZTS: " . ($environment->zts ? 'Yes' : 'No') . "\n"; + echo "DEBUG: " . ($environment->debug ? 'Yes' : 'No') . "\n"; + echo "=====================================================================\n"; + + echo "No tests in this branch yet.\n"; + + echo "All OK\n"; +} + +function output_group_start(Environment $environment, string $name): void +{ + if ($environment->githubAction) { + printf("::group::%s\n", $name); + } else { + printf("%s\n", $name); + } +} + +function output_group_end(Environment $environment): void +{ + if ($environment->githubAction) { + printf("::endgroup::\n"); + } +} + +/** + * Returns getenv('TEST_PHP_OS') if defined, otherwise returns one of + * 'Windows NT', 'Linux', 'FreeBSD', 'Darwin', ... + */ +function detect_os(): string +{ + $os = (string) getenv('TEST_PHP_OS'); + if ($os !== '') { + return $os; + } + + return php_uname('s'); +} + +/** + * Returns getenv('TEST_PHP_CPU_ARCH') if defined, otherwise returns one of + * 'x86', 'x86_64', 'aarch64', ... + */ +function detect_cpu_arch(): string +{ + $cpu = (string) getenv('TEST_PHP_CPU_ARCH'); + if ($cpu !== '') { + return $cpu; + } + + $cpu = php_uname('m'); + if (strtolower($cpu) === 'amd64') { + $cpu = 'x86_64'; + } else if (in_array($cpu, ['i386', 'i686'])) { + $cpu = 'x86'; + } else if ($cpu === 'arm64') { + $cpu = 'aarch64'; + } + + return $cpu; +} + +main($argc, $argv); From 3aaa8d3526c53f3e3a9901853910401bd3eb3aa9 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Tue, 22 Jul 2025 10:39:56 +0200 Subject: [PATCH 07/59] Reset global pointers to prevent use-after-free Closes GH-19212. --- NEWS | 4 +++- ext/opcache/jit/zend_jit.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d52050e3a8e3..a05b577d101b 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.1.34 - +- Opcache: + . Reset global pointers to prevent use-after-free in zend_jit_status(). + (Florian Engelhardt) 03 Jul 2025, PHP 8.1.33 diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 4d2baddb9009..f0225b0c7a88 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -5087,6 +5087,14 @@ ZEND_EXT_API void zend_jit_shutdown(void) #else zend_jit_trace_free_caches(&jit_globals); #endif + + /* Reset global pointers to prevent use-after-free in `zend_jit_status()` + * after gracefully restarting Apache with mod_php, see: + * https://github.com/php/php-src/pull/19212 */ + dasm_ptr = NULL; + dasm_buf = NULL; + dasm_end = NULL; + dasm_size = 0; } static void zend_jit_reset_counters(void) From e9e432a35d8327d0bac84216d1b8afddae3c535f Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 4 Aug 2025 16:16:49 +0200 Subject: [PATCH 08/59] Upgrade to macOS 14 and backport necessary changes --- .github/actions/brew/action.yml | 26 ++++++------- .github/actions/configure-macos/action.yml | 37 ++++++++++--------- .../actions/verify-generated-files/action.yml | 2 +- .github/workflows/push.yml | 4 +- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/.github/actions/brew/action.yml b/.github/actions/brew/action.yml index 5cd8d33cfa6b..fa2acd58d2e5 100644 --- a/.github/actions/brew/action.yml +++ b/.github/actions/brew/action.yml @@ -5,31 +5,27 @@ runs: - shell: bash run: | set -x + + # Patch brew to overwrite always + formula_installer="$(brew --repo)"/Library/Homebrew/formula_installer.rb + code=" keg.link\(verbose: verbose\?" + sudo sed -Ei '' "s/$code.*/$code, overwrite: true\)/" "$formula_installer" + + # Some packages exist on x86 but not arm, or vice versa. + # Install them with reinstall to avoid warnings. + brew reinstall autoconf webp tidy-html5 libzip libsodium icu4c brew install \ - pkg-config \ - autoconf \ bison \ re2c brew install \ - openssl@1.1 \ - curl \ + aspell \ krb5 \ bzip2 \ enchant \ libffi \ - libpng \ - webp \ - freetype \ intltool \ libiconv \ - zlib \ t1lib \ - gd \ - libzip \ - gmp \ - tidy-html5 \ libxml2 \ libjpeg \ - libxslt \ - postgresql - brew link gettext --force + libxslt diff --git a/.github/actions/configure-macos/action.yml b/.github/actions/configure-macos/action.yml index 87627d4f8484..071e31708c21 100644 --- a/.github/actions/configure-macos/action.yml +++ b/.github/actions/configure-macos/action.yml @@ -10,15 +10,15 @@ runs: run: | set -x BREW_OPT="$(brew --prefix)"/opt - export PATH="/usr/local/opt/bison/bin:$PATH" - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/openssl@1.1/lib/pkgconfig" - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/curl/lib/pkgconfig" - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/krb5/lib/pkgconfig" - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/libffi/lib/pkgconfig" - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/libxml2/lib/pkgconfig" - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/libxslt/lib/pkgconfig" - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/zlib/lib/pkgconfig" - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/icu4c@74/lib/pkgconfig" + export PATH="$BREW_OPT/bison/bin:$PATH" + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/openssl@1.1/lib/pkgconfig" + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/curl/lib/pkgconfig" + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/krb5/lib/pkgconfig" + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/libffi/lib/pkgconfig" + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/libxml2/lib/pkgconfig" + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/libxslt/lib/pkgconfig" + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/zlib/lib/pkgconfig" + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/icu4c/lib/pkgconfig" sed -i -e 's/Requires.private:.*//g' "$BREW_OPT/curl/lib/pkgconfig/libcurl.pc" ./buildconf --force ./configure \ @@ -28,8 +28,8 @@ runs: --enable-fpm \ --with-pdo-mysql=mysqlnd \ --with-mysqli=mysqlnd \ - --with-pgsql=/usr/local/opt/libpq \ - --with-pdo-pgsql=/usr/local/opt/libpq \ + --with-pgsql="$BREW_OPT"/libpq \ + --with-pdo-pgsql="$BREW_OPT"/libpq \ --with-pdo-sqlite \ --without-pear \ --enable-gd \ @@ -42,30 +42,31 @@ runs: --enable-soap \ --enable-xmlreader \ --with-xsl \ - --with-tidy=/usr/local/opt/tidy-html5 \ + --with-tidy="$BREW_OPT"/tidy-html5 \ --with-libxml \ --enable-sysvsem \ --enable-sysvshm \ --enable-shmop \ --enable-pcntl \ - --with-readline=/usr/local/opt/readline \ + --with-readline="$BREW_OPT"/readline \ --enable-mbstring \ --with-curl \ - --with-gettext=/usr/local/opt/gettext \ + --with-gettext="$BREW_OPT"/gettext \ --enable-sockets \ - --with-bz2=/usr/local/opt/bzip2 \ + --with-bz2="$BREW_OPT"/bzip2 \ --with-openssl \ - --with-gmp=/usr/local/opt/gmp \ - --with-iconv=/usr/local/opt/libiconv \ + --with-gmp="$BREW_OPT"/gmp \ + --with-iconv="$BREW_OPT"/libiconv \ --enable-bcmath \ --enable-calendar \ --enable-ftp \ - --with-pspell=/usr/local/opt/aspell \ + --with-pspell="$BREW_OPT"/aspell \ --with-kerberos \ --enable-sysvmsg \ --with-ffi \ --enable-zend-test \ --enable-dl-test=shared \ + --enable-intl \ --with-mhash \ --with-sodium \ --enable-dba \ diff --git a/.github/actions/verify-generated-files/action.yml b/.github/actions/verify-generated-files/action.yml index 4bd838f63172..4d26e5f25027 100644 --- a/.github/actions/verify-generated-files/action.yml +++ b/.github/actions/verify-generated-files/action.yml @@ -5,7 +5,7 @@ runs: - shell: bash run: | set -x - [[ "$OSTYPE" == "darwin"* ]] && export PATH="/usr/local/opt/bison/bin:$PATH" + [[ "$OSTYPE" == "darwin"* ]] && export PATH="$(brew --prefix)/opt/bison/bin:$PATH" scripts/dev/genfiles Zend/zend_vm_gen.php build/gen_stub.php -f diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 5353ef7d0ea4..5c1057dd9164 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -113,7 +113,7 @@ jobs: uses: ./.github/actions/verify-generated-files MACOS_DEBUG_NTS: if: github.repository == 'php/php-src' || github.event_name == 'pull_request' - runs-on: macos-13 + runs-on: macos-14 steps: - name: git checkout uses: actions/checkout@v4 @@ -130,7 +130,7 @@ jobs: configurationParameters: --enable-debug --disable-zts - name: make run: |- - export PATH="/usr/local/opt/bison/bin:$PATH" + export PATH="$(brew --prefix)/opt/bison/bin:$PATH" make -j$(sysctl -n hw.logicalcpu) >/dev/null - name: make install run: sudo make install From 1c65cc3998a69f8b33a09e16823a64c4954a6214 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 5 Aug 2025 14:50:18 +0200 Subject: [PATCH 09/59] [skip ci] Group component output in community job --- .github/workflows/nightly.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 38ccb05e0992..ade549e16efe 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -565,14 +565,16 @@ jobs: repositories="amp cache dns file http parallel parser pipeline process serialization socket sync websocket-client websocket-server" X=0 for repository in $repositories; do - printf "Testing amp/%s\n" "$repository" + echo "::group::$repository" git clone "https://github.com/amphp/$repository.git" "amphp-$repository" --depth 1 cd "amphp-$repository" git rev-parse HEAD php /usr/bin/composer install --no-progress --ignore-platform-req=php+ vendor/bin/phpunit || EXIT_CODE=$? + echo "::endgroup::" if [ ${EXIT_CODE:-0} -gt 128 ]; then X=1; + echo "Failed" fi cd .. done @@ -596,14 +598,16 @@ jobs: repositories="async cache child-process datagram dns event-loop promise promise-stream promise-timer stream" X=0 for repository in $repositories; do - printf "Testing reactphp/%s\n" "$repository" + echo "::group::$repository" git clone "https://github.com/reactphp/$repository.git" "reactphp-$repository" --depth 1 cd "reactphp-$repository" git rev-parse HEAD php /usr/bin/composer install --no-progress --ignore-platform-req=php+ vendor/bin/phpunit || EXIT_CODE=$? + echo "::endgroup::" if [ $[EXIT_CODE:-0} -gt 128 ]; then X=1; + echo "Failed" fi cd .. done @@ -634,9 +638,12 @@ jobs: export SYMFONY_DEPRECATIONS_HELPER=max[total]=999 X=0 for component in $(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n'); do + echo "::group::$component" php ./phpunit $component --exclude-group tty,benchmark,intl-data,transient --exclude-group skip || EXIT_CODE=$? + echo "::endgroup::" if [ ${EXIT_CODE:-0} -gt 128 ]; then X=1; + echo "Failed" fi done exit $X From 8199cad99f9c8c9d18b829680001d5185016690a Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Wed, 6 Aug 2025 05:32:36 +0530 Subject: [PATCH 10/59] Fix master branch check in find-target-branch.bat (#19385) --- .github/scripts/windows/find-target-branch.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/windows/find-target-branch.bat b/.github/scripts/windows/find-target-branch.bat index 43b285214971..a0b47f248894 100644 --- a/.github/scripts/windows/find-target-branch.bat +++ b/.github/scripts/windows/find-target-branch.bat @@ -3,6 +3,6 @@ for /f "usebackq tokens=3" %%i in (`findstr PHP_MAJOR_VERSION main\php_version.h`) do set BRANCH=%%i for /f "usebackq tokens=3" %%i in (`findstr PHP_MINOR_VERSION main\php_version.h`) do set BRANCH=%BRANCH%.%%i -if /i "%BRANCH%" equ "8.3" ( +if /i "%BRANCH%" equ "8.5" ( set BRANCH=master ) From a63e97667e84cd6919bdb2c722f5bd0179852565 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Wed, 6 Aug 2025 14:18:43 +0200 Subject: [PATCH 11/59] COMMUNTIY build grouping adjustments Unconditionally execute assignment of EXIT_CODE. Otherwise, the variable bleeds into the next iteration. Also add newline before ::endgroup::. ASAN does not add a trailing newline. --- .github/workflows/nightly.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ade549e16efe..b4266921f84a 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -570,8 +570,9 @@ jobs: cd "amphp-$repository" git rev-parse HEAD php /usr/bin/composer install --no-progress --ignore-platform-req=php+ - vendor/bin/phpunit || EXIT_CODE=$? - echo "::endgroup::" + vendor/bin/phpunit + EXIT_CODE=$? + echo -e "\n::endgroup::" if [ ${EXIT_CODE:-0} -gt 128 ]; then X=1; echo "Failed" @@ -603,8 +604,9 @@ jobs: cd "reactphp-$repository" git rev-parse HEAD php /usr/bin/composer install --no-progress --ignore-platform-req=php+ - vendor/bin/phpunit || EXIT_CODE=$? - echo "::endgroup::" + vendor/bin/phpunit + EXIT_CODE=$? + echo -e "\n::endgroup::" if [ $[EXIT_CODE:-0} -gt 128 ]; then X=1; echo "Failed" @@ -639,8 +641,9 @@ jobs: X=0 for component in $(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n'); do echo "::group::$component" - php ./phpunit $component --exclude-group tty,benchmark,intl-data,transient --exclude-group skip || EXIT_CODE=$? - echo "::endgroup::" + php ./phpunit $component --exclude-group tty,benchmark,intl-data,transient --exclude-group skip + EXIT_CODE=$? + echo -e "\n::endgroup::" if [ ${EXIT_CODE:-0} -gt 128 ]; then X=1; echo "Failed" From 0ac37fb74d899dae4553bb51313fcb8afbb0f56d Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Wed, 6 Aug 2025 15:07:45 +0200 Subject: [PATCH 12/59] [skip ci] Fix Symfony COMMUNITY build for new phpunit version --exclude-group no longer accepts a comma-separated list. Doc block comments are no longer supported, switch to attributes. --- .github/workflows/nightly.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index b4266921f84a..b2846da496e9 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -634,14 +634,14 @@ jobs: php /usr/bin/composer install --no-progress --ignore-platform-req=php+ php ./phpunit install # Test causes a heap-buffer-overflow but I cannot reproduce it locally... - php -r '$c = file_get_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php"); $c = str_replace("public function testSanitizeDeepNestedString()", "/** @group skip */\n public function testSanitizeDeepNestedString()", $c); file_put_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php", $c);' + php -r '$c = file_get_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php"); $c = str_replace("public function testSanitizeDeepNestedString()", "#[\\PHPUnit\\Framework\\Attributes\\Group('"'"'skip'"'"')]\n public function testSanitizeDeepNestedString()", $c); file_put_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php", $c);' # Buggy FFI test in Symfony, see https://github.com/symfony/symfony/issues/47668 - php -r '$c = file_get_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php"); $c = str_replace("public function testCastNonTrailingCharPointer()", "/** @group skip */\n public function testCastNonTrailingCharPointer()", $c); file_put_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php", $c);' + php -r '$c = file_get_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php"); $c = str_replace("public function testCastNonTrailingCharPointer()", "#[\\PHPUnit\\Framework\\Attributes\\Group('"'"'skip'"'"')]\n public function testCastNonTrailingCharPointer()", $c); file_put_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php", $c);' export SYMFONY_DEPRECATIONS_HELPER=max[total]=999 X=0 for component in $(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n'); do echo "::group::$component" - php ./phpunit $component --exclude-group tty,benchmark,intl-data,transient --exclude-group skip + php ./phpunit $component --exclude-group tty --exclude-group benchmark --exclude-group intl-data --exclude-group transient --exclude-group skip EXIT_CODE=$? echo -e "\n::endgroup::" if [ ${EXIT_CODE:-0} -gt 128 ]; then From 2cd9233e42a68267d544bd15373521b7d531da6b Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 7 Aug 2025 13:54:55 +0200 Subject: [PATCH 13/59] Fix ERROR_CODE handling in COMMUNITY build We need || because a non-0 return from the application aborts the execution of the job. --- .github/workflows/nightly.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index b2846da496e9..513ade4a7100 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -570,8 +570,8 @@ jobs: cd "amphp-$repository" git rev-parse HEAD php /usr/bin/composer install --no-progress --ignore-platform-req=php+ - vendor/bin/phpunit - EXIT_CODE=$? + EXIT_CODE=0 + vendor/bin/phpunit || EXIT_CODE=$? echo -e "\n::endgroup::" if [ ${EXIT_CODE:-0} -gt 128 ]; then X=1; @@ -604,8 +604,8 @@ jobs: cd "reactphp-$repository" git rev-parse HEAD php /usr/bin/composer install --no-progress --ignore-platform-req=php+ - vendor/bin/phpunit - EXIT_CODE=$? + EXIT_CODE=0 + vendor/bin/phpunit || EXIT_CODE=$? echo -e "\n::endgroup::" if [ $[EXIT_CODE:-0} -gt 128 ]; then X=1; @@ -641,8 +641,8 @@ jobs: X=0 for component in $(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n'); do echo "::group::$component" - php ./phpunit $component --exclude-group tty --exclude-group benchmark --exclude-group intl-data --exclude-group transient --exclude-group skip - EXIT_CODE=$? + EXIT_CODE=0 + php ./phpunit $component --exclude-group tty --exclude-group benchmark --exclude-group intl-data --exclude-group transient --exclude-group skip || EXIT_CODE=$? echo -e "\n::endgroup::" if [ ${EXIT_CODE:-0} -gt 128 ]; then X=1; From abb7f2879eb46b2e39f146594521d8fb3bb85376 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 12 Aug 2025 14:17:33 +0200 Subject: [PATCH 14/59] [skip ci] Add timeout for FreeBSD Unfortunately, these jobs routinely fail to boot correctly. In this case, they'll stall and block CI for 6 hours until they finally fail. Add a limit to make them fail earlier. --- .github/workflows/nightly.yml | 1 + .github/workflows/push.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 513ade4a7100..ffa43fe744a2 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1086,6 +1086,7 @@ jobs: - zts: ${{ !inputs.run_freebsd_zts && true || '*never*' }} name: "FREEBSD_${{ matrix.zts && 'ZTS' || 'NTS' }}" runs-on: ubuntu-latest + timeout-minutes: 50 steps: - name: git checkout uses: actions/checkout@v4 diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 5c1057dd9164..29fc841dd4e7 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -174,6 +174,7 @@ jobs: if: github.repository == 'php/php-src' || github.event_name == 'pull_request' name: FREEBSD runs-on: ubuntu-latest + timeout-minutes: 50 steps: - name: git checkout uses: actions/checkout@v4 From 2650248a927224aa5b76130d406a691ad774fd38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 13 Aug 2025 19:06:09 +0200 Subject: [PATCH 15/59] Update GitHub Action workflows to `actions/checkout@v5` Keep this up to date in all non-security-only branches, because the node.js runtime for older versions might get deprecated in the future and fixing this for all branches at once is easier. see 45e60e585eed63353301f797c75da4e553ce21ff --- .github/workflows/nightly.yml | 38 +++++++++++++++++------------------ .github/workflows/push.yml | 8 ++++---- .github/workflows/root.yml | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ffa43fe744a2..62ea79650212 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -54,7 +54,7 @@ jobs: runs-on: [self-hosted, gentoo, ppc64] steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: System info @@ -95,7 +95,7 @@ jobs: image: 'alpine:3.20.1' steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: apk @@ -207,7 +207,7 @@ jobs: runs-on: ubuntu-${{ matrix.asan && inputs.asan_ubuntu_version || inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: Create MSSQL container @@ -310,7 +310,7 @@ jobs: FIREBIRD_PASSWORD: test steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: apt @@ -381,7 +381,7 @@ jobs: runs-on: macos-${{ matrix.os }} steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: brew @@ -459,7 +459,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: Create MSSQL container @@ -513,7 +513,7 @@ jobs: USE_TRACKED_ALLOC: 1 steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: apt @@ -717,7 +717,7 @@ jobs: runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: Create MSSQL container @@ -785,7 +785,7 @@ jobs: runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: apt @@ -877,7 +877,7 @@ jobs: runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: apt @@ -927,38 +927,38 @@ jobs: CXX: ccache g++ steps: - name: git checkout PHP - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: path: php ref: ${{ inputs.branch }} - name: git checkout apcu - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: krakjoe/apcu path: apcu - name: git checkout imagick - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: Imagick/imagick path: imagick - name: git checkout memcached - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: php-memcached-dev/php-memcached path: memcached - name: git checkout redis - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: phpredis/phpredis path: redis - name: git checkout xdebug if: false - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: xdebug/xdebug path: xdebug - name: git checkout yaml - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: php/pecl-file_formats-yaml path: yaml @@ -1068,7 +1068,7 @@ jobs: - name: git config run: git config --global core.autocrlf false && git config --global core.eol lf - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: Setup @@ -1089,7 +1089,7 @@ jobs: timeout-minutes: 50 steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} - name: FreeBSD diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 29fc841dd4e7..028255330d1f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -71,7 +71,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Create MSSQL container uses: ./.github/actions/setup-mssql - name: Create Oracle container @@ -116,7 +116,7 @@ jobs: runs-on: macos-14 steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: brew uses: ./.github/actions/brew - name: ccache @@ -163,7 +163,7 @@ jobs: - name: git config run: git config --global core.autocrlf false && git config --global core.eol lf - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup uses: ./.github/actions/setup-windows - name: Build @@ -177,6 +177,6 @@ jobs: timeout-minutes: 50 steps: - name: git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: FreeBSD uses: ./.github/actions/freebsd diff --git a/.github/workflows/root.yml b/.github/workflows/root.yml index 96943a8cfb2a..16418b1aa1d3 100644 --- a/.github/workflows/root.yml +++ b/.github/workflows/root.yml @@ -13,7 +13,7 @@ jobs: outputs: branches: ${{ steps.set-matrix.outputs.branches }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: # Set fetch-depth to 0 to clone the full repository # including all branches. This is required to find From a757f276f95e20c1bd0e5102e6af9cddcdaf0149 Mon Sep 17 00:00:00 2001 From: George Wang Date: Sat, 6 Sep 2025 12:38:13 -0400 Subject: [PATCH 16/59] fix pipe detection for STDERR. --- sapi/litespeed/lsapilib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c index 09cd2e6bf9a7..2ab314d7d73f 100644 --- a/sapi/litespeed/lsapilib.c +++ b/sapi/litespeed/lsapilib.c @@ -634,8 +634,8 @@ static inline int isPipe( int fd ) { char achPeer[128]; socklen_t len = 128; - if (( getpeername( fd, (struct sockaddr *)achPeer, &len ) != 0 )&& - ( errno == ENOTCONN )) + if ((getpeername(fd, (struct sockaddr *)achPeer, &len) != 0 ) + && (errno == ENOTCONN || errno == ENOTSOCK)) return 0; else return 1; From c0f8bb66222a3e16cf3ac24ad75281bffcdacffe Mon Sep 17 00:00:00 2001 From: Jakub Zelenka Date: Tue, 9 Sep 2025 21:57:54 +0200 Subject: [PATCH 17/59] Revert "fix pipe detection for STDERR." This reverts commit a757f276f95e20c1bd0e5102e6af9cddcdaf0149. --- sapi/litespeed/lsapilib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c index 2ab314d7d73f..09cd2e6bf9a7 100644 --- a/sapi/litespeed/lsapilib.c +++ b/sapi/litespeed/lsapilib.c @@ -634,8 +634,8 @@ static inline int isPipe( int fd ) { char achPeer[128]; socklen_t len = 128; - if ((getpeername(fd, (struct sockaddr *)achPeer, &len) != 0 ) - && (errno == ENOTCONN || errno == ENOTSOCK)) + if (( getpeername( fd, (struct sockaddr *)achPeer, &len ) != 0 )&& + ( errno == ENOTCONN )) return 0; else return 1; From be5b2bf4b8fa20273d6bdf82d7c200fda1fc4318 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 11 Sep 2025 14:59:11 +0200 Subject: [PATCH 18/59] [skip ci] Add --enable-zend-max-execution-timers to variation nightly build Only enable for 8.3 because of GH-19786. --- .github/workflows/nightly.yml | 4 ++++ .github/workflows/root.yml | 1 + 2 files changed, 5 insertions(+) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 62ea79650212..a8c8c80d7d50 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -44,6 +44,9 @@ on: skip_wordpress: required: true type: boolean + variation_enable_zend_max_execution_timers: + required: true + type: boolean permissions: contents: read jobs: @@ -199,6 +202,7 @@ jobs: zts: true configuration_parameters: >- CFLAGS="-DZEND_RC_DEBUG=1 -DPROFITABILITY_CHECKS=0 -DZEND_VERIFY_FUNC_INFO=1 -DZEND_VERIFY_TYPE_INFERENCE" + ${{ inputs.variation_enable_zend_max_execution_timers && '--enable-zend-max-execution-timers' || '' }} run_tests_parameters: -d zend_test.observer.enabled=1 -d zend_test.observer.show_output=0 timeout_minutes: 360 test_function_jit: true diff --git a/.github/workflows/root.yml b/.github/workflows/root.yml index 16418b1aa1d3..b70b026eced0 100644 --- a/.github/workflows/root.yml +++ b/.github/workflows/root.yml @@ -64,4 +64,5 @@ jobs: skip_laravel: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }} skip_symfony: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }} skip_wordpress: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }} + variation_enable_zend_max_execution_timers: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 3) || matrix.branch.version[0] >= 9 }} secrets: inherit From 197921a8aa7b2f9af103b439bf913e23d6ed1b98 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 23 Sep 2025 23:41:42 +0200 Subject: [PATCH 19/59] [skip ci] Add 8.6 to nightly_matrix.php --- .github/nightly_matrix.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/nightly_matrix.php b/.github/nightly_matrix.php index 311176ef5e53..846c60e8fd56 100644 --- a/.github/nightly_matrix.php +++ b/.github/nightly_matrix.php @@ -1,7 +1,8 @@ 'master', 'version' => [8, 5]], + ['ref' => 'master', 'version' => [8, 6]], + ['ref' => 'PHP-8.5', 'version' => [8, 5]], ['ref' => 'PHP-8.4', 'version' => [8, 4]], ['ref' => 'PHP-8.3', 'version' => [8, 3]], ['ref' => 'PHP-8.2', 'version' => [8, 2]], From 107075605db6f1b15ce275e345d1c6de04a464b0 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Sun, 28 Sep 2025 09:54:13 +0530 Subject: [PATCH 20/59] Change master branch check to 8.6 --- .github/scripts/windows/find-target-branch.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/windows/find-target-branch.bat b/.github/scripts/windows/find-target-branch.bat index a0b47f248894..44b0bde1ec8c 100644 --- a/.github/scripts/windows/find-target-branch.bat +++ b/.github/scripts/windows/find-target-branch.bat @@ -3,6 +3,6 @@ for /f "usebackq tokens=3" %%i in (`findstr PHP_MAJOR_VERSION main\php_version.h`) do set BRANCH=%%i for /f "usebackq tokens=3" %%i in (`findstr PHP_MINOR_VERSION main\php_version.h`) do set BRANCH=%BRANCH%.%%i -if /i "%BRANCH%" equ "8.5" ( +if /i "%BRANCH%" equ "8.6" ( set BRANCH=master ) From 66708de8417d743aba4f542ee6476b646cdb918b Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Thu, 2 Oct 2025 15:53:53 +0200 Subject: [PATCH 21/59] Upgrade Alpine in nightly job Closes GH-20044 --- .github/workflows/nightly.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index a8c8c80d7d50..e0322e3b1be2 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -93,9 +93,9 @@ jobs: ALPINE: if: inputs.run_alpine name: ALPINE_X64_ASAN_UBSAN_DEBUG_ZTS - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 container: - image: 'alpine:3.20.1' + image: 'alpine:3.22' steps: - name: git checkout uses: actions/checkout@v5 @@ -103,11 +103,6 @@ jobs: ref: ${{ inputs.branch }} - name: apk uses: ./.github/actions/apk - - name: LLVM 17 (ASAN-only) - # libclang_rt.asan-x86_64.a is provided by compiler-rt, and only for clang17: - # https://pkgs.alpinelinux.org/contents?file=libclang_rt.asan-x86_64.a&path=&name=&branch=v3.20 - run: | - apk add clang17 compiler-rt - name: System info run: | echo "::group::Show host CPU info" @@ -122,8 +117,8 @@ jobs: configurationParameters: >- CFLAGS="-fsanitize=undefined,address -fno-sanitize=function -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address -fno-sanitize=function" - CC=clang-17 - CXX=clang++-17 + CC=clang-20 + CXX=clang++-20 --enable-debug --enable-zts skipSlow: true # FIXME: This should likely include slow extensions From 1c8363d2bfe214c142b3e17bf7303b6c338ac41a Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 13 Sep 2025 00:15:01 +0200 Subject: [PATCH 22/59] Fix curl build failure on macOS+curl 8.16 --- ext/curl/interface.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 807b27cb78c9..4df24cff1b5b 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1453,11 +1453,11 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string) /* }}} */ /* {{{ curl_progress */ -static size_t curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) +static int curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) { php_curl *ch = (php_curl *)clientp; php_curl_callback *t = ch->handlers.progress; - size_t rval = 0; + int rval = 0; #if PHP_CURL_DEBUG fprintf(stderr, "curl_progress() called\n"); @@ -1818,8 +1818,8 @@ static void _php_curl_set_default_options(php_curl *ch) { char *cainfo; - curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1); - curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); + curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1L); + curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0L); curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str); curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write); curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch); @@ -1828,10 +1828,10 @@ static void _php_curl_set_default_options(php_curl *ch) curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header); curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch); #ifndef ZTS - curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1); + curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1L); #endif - curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120); - curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */ + curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120L); + curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20L); /* prevent infinite redirects */ cainfo = INI_STR("openssl.cafile"); if (!(cainfo && cainfo[0] != '\0')) { @@ -2807,7 +2807,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i /* no need to build the mime structure for empty hashtables; also works around https://github.com/curl/curl/issues/6455 */ curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, ""); - error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, 0); + error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, 0L); } else { return build_mime_structure_from_hash(ch, zvalue); } @@ -2871,7 +2871,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i case CURLOPT_POSTREDIR: lval = zval_get_long(zvalue); - error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, lval & CURL_REDIR_POST_ALL); + error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, (long) (lval & CURL_REDIR_POST_ALL)); break; /* the following options deal with files, therefore the open_basedir check @@ -2906,11 +2906,11 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i if (zend_is_true(zvalue)) { curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, curl_debug); curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, (void *)ch); - curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 1); + curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 1L); } else { curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, NULL); curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, NULL); - curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); + curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0L); } break; From da75e41a6f7e1d64904e45612eaafe4a636fe502 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 22 Sep 2025 10:55:59 +0200 Subject: [PATCH 23/59] Fix curl 8.16.0 compilation with zts --- ext/curl/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 4df24cff1b5b..f8f0d1cec358 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1842,7 +1842,7 @@ static void _php_curl_set_default_options(php_curl *ch) } #ifdef ZTS - curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1); + curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1L); #endif } /* }}} */ From b810a235870f7fbb377fa50470970eaf16d796ce Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 23 Sep 2025 14:14:09 +0200 Subject: [PATCH 24/59] Fix more curl 8.16 issues The CURLOPT_FOLLOWLOCATION seems like a gcc bug, where the integer extension of bool to long is lost, but I was unable to reproduce on godbolt.org. --- ext/curl/interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/curl/interface.c b/ext/curl/interface.c index f8f0d1cec358..c56a1b01f2fa 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -2289,7 +2289,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i lval = zval_get_long(zvalue); if (lval == 1) { php_error_docref(NULL, E_NOTICE, "CURLOPT_SSL_VERIFYHOST no longer accepts the value 1, value 2 will be used instead"); - error = curl_easy_setopt(ch->cp, option, 2); + error = curl_easy_setopt(ch->cp, option, 2L); break; } ZEND_FALLTHROUGH; @@ -2789,7 +2789,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i case CURLOPT_FOLLOWLOCATION: lval = zend_is_true(zvalue); - error = curl_easy_setopt(ch->cp, option, lval); + error = curl_easy_setopt(ch->cp, option, (long) lval); break; case CURLOPT_HEADERFUNCTION: From 36859ad97753f6d2e550d57823111d91f0ad0ce9 Mon Sep 17 00:00:00 2001 From: Jakub Zelenka Date: Tue, 7 Oct 2025 12:33:26 +0200 Subject: [PATCH 25/59] Fix curl_setopt_ssl test for curl 8.16 --- ext/curl/tests/curl_setopt_ssl.phpt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/curl/tests/curl_setopt_ssl.phpt b/ext/curl/tests/curl_setopt_ssl.phpt index 11d8fff702a8..ff08528321a0 100644 --- a/ext/curl/tests/curl_setopt_ssl.phpt +++ b/ext/curl/tests/curl_setopt_ssl.phpt @@ -18,9 +18,13 @@ if ($curl_version['version_number'] < 0x074700) { --FILE-- Date: Tue, 7 Oct 2025 14:25:08 +0200 Subject: [PATCH 26/59] Update NEWS with info about curl 8.16 compat fixes --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index a05b577d101b..998b5d97d635 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.1.34 +- Curl: + . Fix curl build and test failures with version 8.16. + (nielsdos, ilutov, Jakub Zelenka) + - Opcache: . Reset global pointers to prevent use-after-free in zend_jit_status(). (Florian Engelhardt) From 2f2fb1fbf1117f642cd1efdf33e431d42ee910ee Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 13 Oct 2025 20:48:24 +0000 Subject: [PATCH 27/59] Skip lc_ctype_inheritance.phpt on macos 15+ --- Zend/tests/lc_ctype_inheritance.phpt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Zend/tests/lc_ctype_inheritance.phpt b/Zend/tests/lc_ctype_inheritance.phpt index 8c968f0615e6..69de59f69ac8 100644 --- a/Zend/tests/lc_ctype_inheritance.phpt +++ b/Zend/tests/lc_ctype_inheritance.phpt @@ -2,6 +2,9 @@ Do not inherit LC_CTYPE from environment --SKIPIF-- =')) { + die('skip macOS 15 inherits LC_CTYPE into the thread locale'); +} if (!setlocale(LC_CTYPE, "de_DE", "de-DE")) die("skip requires de_DE locale"); ?> --ENV-- From 9a2113a10443c214ae714b94fdeaa2e5c26056aa Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 9 Jan 2024 20:05:51 +0300 Subject: [PATCH 28/59] Disable inlining and inter-procedure-analyses for zend_string_equal_val() function that may be overriden for valgrind (#13099) This is a more safely way to fix GH-9068 --- Zend/zend_string.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Zend/zend_string.c b/Zend/zend_string.c index c21b4f5d4610..afc7325713c9 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -366,6 +366,7 @@ ZEND_API void zend_interned_strings_switch_storage(bool request) } } +#if defined(__GNUC__) && (defined(__i386__) || (defined(__x86_64__) && !defined(__ILP32__))) /* Even if we don't build with valgrind support, include the symbol so that valgrind available * only at runtime will not result in false positives. */ #ifndef I_REPLACE_SONAME_FNNAME_ZU @@ -373,29 +374,20 @@ ZEND_API void zend_interned_strings_switch_storage(bool request) #endif /* See GH-9068 */ -#if defined(__GNUC__) && (__GNUC__ >= 11 || defined(__clang__)) && __has_attribute(no_caller_saved_registers) -# define NO_CALLER_SAVED_REGISTERS __attribute__((no_caller_saved_registers)) -# ifndef __clang__ -# pragma GCC push_options -# pragma GCC target ("general-regs-only") -# define POP_OPTIONS -# endif +#if __has_attribute(noipa) +# define NOIPA __attribute__((noipa)) #else -# define NO_CALLER_SAVED_REGISTERS +# define NOIPA #endif -ZEND_API bool ZEND_FASTCALL NO_CALLER_SAVED_REGISTERS I_REPLACE_SONAME_FNNAME_ZU(NONE,zend_string_equal_val)(zend_string *s1, zend_string *s2) +ZEND_API bool ZEND_FASTCALL I_REPLACE_SONAME_FNNAME_ZU(NONE,zend_string_equal_val)(zend_string *s1, zend_string *s2) { return !memcmp(ZSTR_VAL(s1), ZSTR_VAL(s2), ZSTR_LEN(s1)); } - -#ifdef POP_OPTIONS -# pragma GCC pop_options -# undef POP_OPTIONS #endif #if defined(__GNUC__) && defined(__i386__) -ZEND_API bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string *s2) +ZEND_API zend_never_inline NOIPA bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string *s2) { const char *ptr = ZSTR_VAL(s1); uintptr_t delta = (uintptr_t) s2 - (uintptr_t) s1; @@ -433,7 +425,7 @@ ZEND_API bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string * } #elif defined(__GNUC__) && defined(__x86_64__) && !defined(__ILP32__) -ZEND_API bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string *s2) +ZEND_API zend_never_inline NOIPA bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string *s2) { const char *ptr = ZSTR_VAL(s1); uintptr_t delta = (uintptr_t) s2 - (uintptr_t) s1; From b094d5a5885ad757f3b9edffe9ddc8197bef60d5 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Fri, 17 Oct 2025 13:04:11 +0200 Subject: [PATCH 29/59] [skip ci] Skip suspicious fpm tests on GH actions & macOS There have been misterious macOS failures with the following error for a long time, which would usually happen 1-2x per nightly run: > The hosted runner lost communication with the server. Anything in your > workflow that terminates the runner process, starves it for CPU/Memory, or > blocks its network access can cause this error. After way too much debugging, it looks like this is caused by the two fpm tests skipped in this commit. When there's a failure, the responsible test will run for at least 120 seconds until the job is eventually killed by GitHub Actions. It's not clear yet why the tests stall. Debugging this is a PITA because the GitHub Actions log gets partially lost for killed jobs. It took an external log server to actually figure out where the job fails. Let's disable the tests first to be sure this actually solves the issue. --- sapi/fpm/tests/bug74083-concurrent-reload.phpt | 1 + sapi/fpm/tests/bug76601-reload-child-signals.phpt | 1 + 2 files changed, 2 insertions(+) diff --git a/sapi/fpm/tests/bug74083-concurrent-reload.phpt b/sapi/fpm/tests/bug74083-concurrent-reload.phpt index ad5d560abae4..5fed01f798b1 100644 --- a/sapi/fpm/tests/bug74083-concurrent-reload.phpt +++ b/sapi/fpm/tests/bug74083-concurrent-reload.phpt @@ -4,6 +4,7 @@ Concurrent reload signals should not kill PHP-FPM master process. (Bug: #74083) --FILE-- --FILE-- Date: Fri, 17 Oct 2025 13:21:49 +0200 Subject: [PATCH 30/59] [skip ci] Fix typo Should've been skip, not flaky... --- sapi/fpm/tests/bug74083-concurrent-reload.phpt | 2 +- sapi/fpm/tests/bug76601-reload-child-signals.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/fpm/tests/bug74083-concurrent-reload.phpt b/sapi/fpm/tests/bug74083-concurrent-reload.phpt index 5fed01f798b1..f37085d65c4c 100644 --- a/sapi/fpm/tests/bug74083-concurrent-reload.phpt +++ b/sapi/fpm/tests/bug74083-concurrent-reload.phpt @@ -4,7 +4,7 @@ Concurrent reload signals should not kill PHP-FPM master process. (Bug: #74083) --FILE-- --FILE-- Date: Mon, 20 Oct 2025 12:43:02 +0200 Subject: [PATCH 31/59] .github: Bust the nightly CI cache on Sunday instead of Monday (#20242) The nightly matrix with an empty cache takes several hours to complete due to the amount of jobs. This will effectively block the entire CI for the php organization since there is an organization-wide limit of 20 jobs. Move the cache buster job to Sunday to make it less likely for folks to fight with the Nightly build for resources. --- .github/nightly_matrix.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/nightly_matrix.php b/.github/nightly_matrix.php index 846c60e8fd56..c1f562754268 100644 --- a/.github/nightly_matrix.php +++ b/.github/nightly_matrix.php @@ -49,8 +49,8 @@ function get_current_version(): array { $trigger = $argv[1] ?? 'schedule'; $attempt = (int) ($argv[2] ?? 1); -$monday = date('w', time()) === '1'; -$discard_cache = $monday +$sunday = date('w', time()) === '0'; +$discard_cache = $sunday || ($trigger === 'schedule' && $attempt !== 1) || $trigger === 'workflow_dispatch'; if ($discard_cache) { From 90bc40ecc0f0d2bf62e97c42256bd10015db3b5e Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 20 Oct 2025 17:53:00 +0200 Subject: [PATCH 32/59] Create separate workflow for nightly slack notification Closes GH-20248 --- .github/actions/notify-slack/action.yml | 10 ----- .github/workflows/nightly-results.yml | 16 ++++++++ .github/workflows/nightly.yml | 51 ------------------------- .github/workflows/root.yml | 5 --- 4 files changed, 16 insertions(+), 66 deletions(-) delete mode 100644 .github/actions/notify-slack/action.yml create mode 100644 .github/workflows/nightly-results.yml diff --git a/.github/actions/notify-slack/action.yml b/.github/actions/notify-slack/action.yml deleted file mode 100644 index 1ff425b51c6a..000000000000 --- a/.github/actions/notify-slack/action.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: Notify Slack -inputs: - token: - required: true -runs: - using: composite - steps: - - shell: bash - run: >- - curl -X POST -H 'Content-type: application/json' --data '{"attachments": [{"text": "Job in *nightly* failed", "footer": "", "color": "danger", "mrkdwn_in": ["text"]}]}' ${{ inputs.token }} diff --git a/.github/workflows/nightly-results.yml b/.github/workflows/nightly-results.yml new file mode 100644 index 000000000000..c1c4da72ca56 --- /dev/null +++ b/.github/workflows/nightly-results.yml @@ -0,0 +1,16 @@ +name: Nightly results +on: + workflow_run: + workflows: + - Nightly + types: + - completed +jobs: + on-failure: + runs-on: ubuntu-latest + if: ${{ github.repository == 'php/php-src' && github.event.workflow_run.conclusion == 'failure' }} + steps: + - run: | + export DEBIAN_FRONTEND=noninteractive + sudo apt-get install -y curl + curl -X POST -H 'Content-type: application/json' --data '{"attachments": [{"text": "Job in *nightly* failed", "footer": "<${{ github.event.workflow_run.jobs_url }}|View Run>", "color": "danger", "mrkdwn_in": ["text"]}]}' ${{ secrets.ACTION_MONITORING_SLACK }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e0322e3b1be2..c360146508b9 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -136,12 +136,6 @@ jobs: -d opcache.enable_cli=1 - name: Extra tests uses: ./.github/actions/extra-tests - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} - LINUX_X64: services: mysql: @@ -273,11 +267,6 @@ jobs: uses: ./.github/actions/extra-tests - name: Verify generated files are up to date uses: ./.github/actions/verify-generated-files - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} LINUX_X32: strategy: fail-fast: false @@ -362,11 +351,6 @@ jobs: -d opcache.enable_cli=1 - name: Extra tests uses: ./.github/actions/extra-tests - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} MACOS: strategy: fail-fast: false @@ -425,11 +409,6 @@ jobs: uses: ./.github/actions/extra-tests - name: Verify generated files are up to date uses: ./.github/actions/verify-generated-files - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} COVERAGE_DEBUG_NTS: if: inputs.branch == 'master' services: @@ -491,11 +470,6 @@ jobs: fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} verbose: true - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} COMMUNITY: strategy: fail-fast: false @@ -683,11 +657,6 @@ jobs: if [ $EXIT_CODE -gt 128 ]; then exit 1 fi - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} OPCACHE_VARIATION: services: mysql: @@ -774,11 +743,6 @@ jobs: -d opcache.file_cache_only=1 - name: Verify generated files are up to date uses: ./.github/actions/verify-generated-files - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} MSAN: name: MSAN runs-on: ubuntu-${{ inputs.ubuntu_version }} @@ -866,11 +830,6 @@ jobs: -d opcache.enable_cli=1 - name: Verify generated files are up to date uses: ./.github/actions/verify-generated-files - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} LIBMYSQLCLIENT: name: LIBMYSQLCLIENT runs-on: ubuntu-${{ inputs.ubuntu_version }} @@ -913,11 +872,6 @@ jobs: withMysqli: ${{ inputs.libmysqlclient_with_mysqli }} - name: Verify generated files are up to date uses: ./.github/actions/verify-generated-files - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} PECL: if: inputs.branch == 'master' runs-on: ubuntu-22.04 @@ -1025,11 +979,6 @@ jobs: /opt/php/bin/phpize ./configure --prefix=/opt/php --with-php-config=/opt/php/bin/php-config make -j$(/usr/bin/nproc) - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} WINDOWS: strategy: fail-fast: false diff --git a/.github/workflows/root.yml b/.github/workflows/root.yml index b70b026eced0..4062358fcbc9 100644 --- a/.github/workflows/root.yml +++ b/.github/workflows/root.yml @@ -31,11 +31,6 @@ jobs: - name: Generate Matrix id: set-matrix run: php .github/nightly_matrix.php "${{ github.event_name }}" "${{ github.run_attempt }}" "${{ github.head_ref || github.ref_name }}" - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} NIGHTLY: needs: GENERATE_MATRIX name: ${{ matrix.branch.ref }} From 99076ebfb01cbef619263656684eb025fc87de2d Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 21 Oct 2025 17:52:04 +0200 Subject: [PATCH 33/59] [skip ci] Auto-mark SKIP_PERF_SENSITIVE tests as flaky These can occasionally fail in CI. --- run-tests.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/run-tests.php b/run-tests.php index 070229ec1d6a..07496d31a567 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2881,6 +2881,11 @@ function is_flaky(TestFile $test): bool if ($test->hasSection('FLAKY')) { return true; } + if ($test->hasSection('SKIPIF')) { + if (strpos($test->getSection('SKIPIF'), 'SKIP_PERF_SENSITIVE') !== false) { + return true; + } + } if (!$test->hasSection('FILE')) { return false; } From 7877de29e0204203b8d83ae9256ee9fb331ca43b Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 21 Oct 2025 17:56:17 +0200 Subject: [PATCH 34/59] [skip ci] Fix nightly notification workflow url jobs_url is a link to the api, rather than the website. Also tweak wording, as we now only send one notification per workflow, rather than per failed job. --- .github/workflows/nightly-results.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly-results.yml b/.github/workflows/nightly-results.yml index c1c4da72ca56..a222582da1c6 100644 --- a/.github/workflows/nightly-results.yml +++ b/.github/workflows/nightly-results.yml @@ -13,4 +13,4 @@ jobs: - run: | export DEBIAN_FRONTEND=noninteractive sudo apt-get install -y curl - curl -X POST -H 'Content-type: application/json' --data '{"attachments": [{"text": "Job in *nightly* failed", "footer": "<${{ github.event.workflow_run.jobs_url }}|View Run>", "color": "danger", "mrkdwn_in": ["text"]}]}' ${{ secrets.ACTION_MONITORING_SLACK }} + curl -X POST -H 'Content-type: application/json' --data '{"attachments": [{"text": "Job(s) in *nightly* failed", "footer": "<${{ github.event.workflow_run.html_url }}|View Run>", "color": "danger", "mrkdwn_in": ["text"]}]}' ${{ secrets.ACTION_MONITORING_SLACK }} From 20654ce4c9644541e80bf9c97c8bb24f2dcaf186 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 28 Oct 2025 00:48:19 +0100 Subject: [PATCH 35/59] [skip ci] Unparallelize imap It's removed for PHP 8.4 anyway, and still regularly causes "Mailbox already exists" errors despite the flaky flag. --- ext/imap/tests/CONFLICTS | 1 + ext/standard/tests/mail/CONFLICTS | 1 + 2 files changed, 2 insertions(+) create mode 100644 ext/imap/tests/CONFLICTS create mode 100644 ext/standard/tests/mail/CONFLICTS diff --git a/ext/imap/tests/CONFLICTS b/ext/imap/tests/CONFLICTS new file mode 100644 index 000000000000..c301c0ffaca1 --- /dev/null +++ b/ext/imap/tests/CONFLICTS @@ -0,0 +1 @@ +imap diff --git a/ext/standard/tests/mail/CONFLICTS b/ext/standard/tests/mail/CONFLICTS new file mode 100644 index 000000000000..c301c0ffaca1 --- /dev/null +++ b/ext/standard/tests/mail/CONFLICTS @@ -0,0 +1 @@ +imap From c3d6bf65d543674534cf3688df045af717c8bbfd Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Fri, 31 Oct 2025 23:43:24 +0100 Subject: [PATCH 36/59] Update zlib test to use separate file for flock() This should prevent the nightly failures that fail with permission denied on platforms with mandatory locks. Closes GH-20351. --- ext/zlib/tests/zlib_flock.txt.gz | Bin 0 -> 150 bytes ext/zlib/tests/zlib_wrapper_flock_basic.phpt | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 ext/zlib/tests/zlib_flock.txt.gz diff --git a/ext/zlib/tests/zlib_flock.txt.gz b/ext/zlib/tests/zlib_flock.txt.gz new file mode 100644 index 0000000000000000000000000000000000000000..07805db7558078115fc0dc63a4426a87508d382a GIT binary patch literal 150 zcmV;H0BQdpiwFo?U!X()128Z&E_8Tw06mQ{4gxU@1pB;VJ3d0g3#iS-cZmqL6gx!W z^%x}RygS!d1Kh@V0JhN>q*^qS#RPf;R27L%W^soQ` E06hOe-2eap literal 0 HcmV?d00001 diff --git a/ext/zlib/tests/zlib_wrapper_flock_basic.phpt b/ext/zlib/tests/zlib_wrapper_flock_basic.phpt index 95329dd003eb..774c342f5d48 100644 --- a/ext/zlib/tests/zlib_wrapper_flock_basic.phpt +++ b/ext/zlib/tests/zlib_wrapper_flock_basic.phpt @@ -4,7 +4,7 @@ Test function stream_get_meta_data on a zlib stream zlib --FILE-- Date: Wed, 5 Nov 2025 12:29:31 +0100 Subject: [PATCH 37/59] [skip ci] Avoid potential network port conflict in tests These tests: - ext/standard/tests/network/udp4loop.phpt - ext/sockets/tests/socket_create_listen.phpt - ext/sockets/tests/socket_create_listen-win32.phpt all use port 31338. socket_create_listen.phpt and its win32 variant are mutually exclusive, so they can't conflict. While udp4loop.phpt tries multiple ports, the other tests do not. If udp4loop.phpt runs first and socket_create_listen.phpt starts before it ends, the port is still blocked. Bump the start port for udp4loop.phpt to avoid conflicts. --- ext/standard/tests/network/udp4loop.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/tests/network/udp4loop.phpt b/ext/standard/tests/network/udp4loop.phpt index 92709233ba19..bde3f8dcef56 100644 --- a/ext/standard/tests/network/udp4loop.phpt +++ b/ext/standard/tests/network/udp4loop.phpt @@ -3,7 +3,7 @@ Streams Based IPv4 UDP Loopback test --FILE-- Date: Thu, 6 Nov 2025 14:15:56 +0100 Subject: [PATCH 38/59] [skip ci] Relax Zend/tests/concat_003.phpt This test frequently fails in CI, where it took 1.3s, including a repeat due to being marked as flaky. Bump this limit with a generous margin. --- Zend/tests/concat_003.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/tests/concat_003.phpt b/Zend/tests/concat_003.phpt index dc22bae1a720..52594dffcfd2 100644 --- a/Zend/tests/concat_003.phpt +++ b/Zend/tests/concat_003.phpt @@ -11,7 +11,7 @@ if (getenv('SKIP_PERF_SENSITIVE')) die("skip performance sensitive test"); $time = microtime(TRUE); /* This might vary on Linux/Windows, so the worst case and also count in slow machines. */ -$t_max = 1.0; +$t_max = 2.0; $datas = array_fill(0, 220000, [ '000.000.000.000', From bdf62b55bb9ba0847c9c10708ce06357723c5546 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 5 Nov 2025 09:34:14 -0500 Subject: [PATCH 39/59] ext/pcre/tests: support libpcre2-10.47 In the latest version of libpcre2, the offsets appearing in some "compilation failed" warnings have increased by one, as a result of https://github.com/PCRE2Project/pcre2/pull/756 This is causing spurious test failures, so in this commit we replace the hard-coded offsets by a regex that matches both values. Gentoo-bug: https://bugs.gentoo.org/965018 Closes GH-20397 --- ext/pcre/tests/grep2.phpt | 2 +- ext/pcre/tests/pcre_extra.phpt | 4 ++-- ext/pcre/tests/split.phpt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/pcre/tests/grep2.phpt b/ext/pcre/tests/grep2.phpt index 9721dfbd9eec..a953b13c49d5 100644 --- a/ext/pcre/tests/grep2.phpt +++ b/ext/pcre/tests/grep2.phpt @@ -21,7 +21,7 @@ var_dump(preg_last_error() == PREG_RECURSION_LIMIT_ERROR); ?> --EXPECTF-- -Warning: preg_grep(): Compilation failed: quantifier does not follow a repeatable item at offset 0 in %sgrep2.php on line %d +Warning: preg_grep(): Compilation failed: quantifier does not follow a repeatable item at offset %r(0|1)%r in %sgrep2.php on line %d bool(false) array(3) { [5]=> diff --git a/ext/pcre/tests/pcre_extra.phpt b/ext/pcre/tests/pcre_extra.phpt index 730c7299390c..660e0a1488a1 100644 --- a/ext/pcre/tests/pcre_extra.phpt +++ b/ext/pcre/tests/pcre_extra.phpt @@ -8,8 +8,8 @@ var_dump(preg_match('/\y/X', '\y')); ?> --EXPECTF-- -Warning: preg_match(): Compilation failed: unrecognized character follows \ at offset 1 in %spcre_extra.php on line 3 +Warning: preg_match(): Compilation failed: unrecognized character follows \ at offset %r(1|2)%r in %spcre_extra.php on line 3 bool(false) -Warning: preg_match(): Compilation failed: unrecognized character follows \ at offset 1 in %spcre_extra.php on line 4 +Warning: preg_match(): Compilation failed: unrecognized character follows \ at offset %r(1|2)%r in %spcre_extra.php on line 4 bool(false) diff --git a/ext/pcre/tests/split.phpt b/ext/pcre/tests/split.phpt index df4b9af92f2f..27f1c85b433e 100644 --- a/ext/pcre/tests/split.phpt +++ b/ext/pcre/tests/split.phpt @@ -16,7 +16,7 @@ var_dump(preg_split('/\d*/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY)); ?> --EXPECTF-- -Warning: preg_split(): Compilation failed: quantifier does not follow a repeatable item at offset 0 in %ssplit.php on line %d +Warning: preg_split(): Compilation failed: quantifier does not follow a repeatable item at offset %r(0|1)%r in %ssplit.php on line %d bool(false) array(3) { [0]=> From 599d5ae64ce47ae7d4b75e1c55d6396fa840f083 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 17 Nov 2025 15:14:24 +0100 Subject: [PATCH 40/59] [skip ci] Fix Symfony PHP requirements in community build Symfony 8.1 and 8.0 now require PHP 8.4. Use 7.4 for PHP 8.3 and 8.2 builds. PHP 8.1 continues to be skipped. Sadly, this will need to be updated sporadically. Closes GH-20512 --- .github/workflows/nightly.yml | 11 ++++++----- .github/workflows/root.yml | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c360146508b9..909a412e796e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -38,9 +38,9 @@ on: skip_laravel: required: true type: boolean - skip_symfony: + symfony_version: required: true - type: boolean + type: string skip_wordpress: required: true type: boolean @@ -599,9 +599,9 @@ jobs: exit 1 fi - name: Test Symfony - if: ${{ !cancelled() && !inputs.skip_symfony }} + if: ${{ !cancelled() && inputs.symfony_version != '' }} run: | - git clone https://github.com/symfony/symfony.git --depth=1 + git clone https://github.com/symfony/symfony.git --depth=1 --branch="${{ inputs.symfony_version }}" cd symfony git rev-parse HEAD php /usr/bin/composer install --no-progress --ignore-platform-req=php+ @@ -635,7 +635,8 @@ jobs: exit 1 fi - name: 'Symfony Preloading' - if: ${{ !cancelled() && !inputs.skip_symfony }} + # composer create-project will automatically pick the right Symfony version for us. + if: ${{ !cancelled() && inputs.symfony_version != '' }} run: | php /usr/bin/composer create-project symfony/symfony-demo symfony_demo --no-progress --ignore-platform-req=php+ cd symfony_demo diff --git a/.github/workflows/root.yml b/.github/workflows/root.yml index 4062358fcbc9..ea23349fd692 100644 --- a/.github/workflows/root.yml +++ b/.github/workflows/root.yml @@ -57,7 +57,9 @@ jobs: windows_version: '2022' vs_crt_version: ${{ ((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) && 'vs17') || 'vs16' }} skip_laravel: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }} - skip_symfony: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }} + symfony_version: ${{ (((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9) && '8.1') + || ((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 2) && '7.4') + || '' }} skip_wordpress: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }} variation_enable_zend_max_execution_timers: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 3) || matrix.branch.version[0] >= 9 }} secrets: inherit From f7fb13eb07e8a75c1ed24dcf4edb177879c24f5d Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 2 Dec 2025 16:26:50 +0100 Subject: [PATCH 41/59] Suppress libxml deprecations Closes GH-20538 --- ext/dom/document.c | 12 ++++++++++++ ext/libxml/libxml.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/ext/dom/document.c b/ext/dom/document.c index 431d69a89dcf..15b5d98131c1 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1437,12 +1437,16 @@ PHP_METHOD(DOMDocument, save) doc_props = dom_get_doc_props(intern->document); format = doc_props->formatoutput; if (options & LIBXML_SAVE_NOEMPTYTAG) { + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") saveempty = xmlSaveNoEmptyTags; xmlSaveNoEmptyTags = 1; + ZEND_DIAGNOSTIC_IGNORED_END } bytes = xmlSaveFormatFileEnc(file, docp, NULL, format); if (options & LIBXML_SAVE_NOEMPTYTAG) { + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") xmlSaveNoEmptyTags = saveempty; + ZEND_DIAGNOSTIC_IGNORED_END } if (bytes == -1) { RETURN_FALSE; @@ -1489,12 +1493,16 @@ PHP_METHOD(DOMDocument, saveXML) RETURN_FALSE; } if (options & LIBXML_SAVE_NOEMPTYTAG) { + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") saveempty = xmlSaveNoEmptyTags; xmlSaveNoEmptyTags = 1; + ZEND_DIAGNOSTIC_IGNORED_END } xmlNodeDump(buf, docp, node, 0, format); if (options & LIBXML_SAVE_NOEMPTYTAG) { + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") xmlSaveNoEmptyTags = saveempty; + ZEND_DIAGNOSTIC_IGNORED_END } mem = (xmlChar*) xmlBufferContent(buf); if (!mem) { @@ -1505,13 +1513,17 @@ PHP_METHOD(DOMDocument, saveXML) xmlBufferFree(buf); } else { if (options & LIBXML_SAVE_NOEMPTYTAG) { + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") saveempty = xmlSaveNoEmptyTags; xmlSaveNoEmptyTags = 1; + ZEND_DIAGNOSTIC_IGNORED_END } /* Encoding is handled from the encoding property set on the document */ xmlDocDumpFormatMemory(docp, &mem, &size, format); if (options & LIBXML_SAVE_NOEMPTYTAG) { + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") xmlSaveNoEmptyTags = saveempty; + ZEND_DIAGNOSTIC_IGNORED_END } if (!size || !mem) { RETURN_FALSE; diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index 3311346d4bcf..f60aa1bf76b6 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -429,9 +429,11 @@ php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc) /* Allocate the Input buffer front-end. */ ret = xmlAllocParserInputBuffer(enc); if (ret != NULL) { + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") ret->context = context; ret->readcallback = php_libxml_streams_IO_read; ret->closecallback = php_libxml_streams_IO_close; + ZEND_DIAGNOSTIC_IGNORED_END } else php_libxml_streams_IO_close(context); @@ -679,9 +681,12 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL, } else { /* make stream not being closed when the zval is freed */ GC_ADDREF(stream->res); + + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") pib->context = stream; pib->readcallback = php_libxml_streams_IO_read; pib->closecallback = php_libxml_streams_IO_close; + ZEND_DIAGNOSTIC_IGNORED_END ret = xmlNewIOInputStream(context, pib, enc); if (ret == NULL) { From bd67ba66a892ea63cd70c9a7fec72c7094183037 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Thu, 6 Nov 2025 22:42:03 +0100 Subject: [PATCH 42/59] dom: Fix compile warning due to misplaced const cast --- ext/dom/document.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/dom/document.c b/ext/dom/document.c index 15b5d98131c1..5f06f8dc2a80 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1120,7 +1120,7 @@ PHP_METHOD(DOMDocument, __construct) } if (encoding_len > 0) { - docp->encoding = (const xmlChar *) xmlStrdup((xmlChar *) encoding); + docp->encoding = xmlStrdup((const xmlChar *) encoding); } intern = Z_DOMOBJ_P(ZEND_THIS); From 903fcb45c35c36857840ec7e2c5be4b3c4e0b6e9 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 19 May 2025 19:10:27 +0200 Subject: [PATCH 43/59] Fix deprecation warning for libxml SAX header (#18594) This header is deprecated, but fortunately it isn't actually used. --- ext/dom/document.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/dom/document.c b/ext/dom/document.c index 5f06f8dc2a80..1987cc38320b 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -22,7 +22,6 @@ #include "php.h" #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" -#include #include #ifdef LIBXML_SCHEMAS_ENABLED #include From dd2179433c0b85a5a841ab6658781f6339b85376 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Tue, 2 Dec 2025 20:09:31 +0100 Subject: [PATCH 44/59] xml: Backport more deprecation fixes --- ext/xml/compat.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ext/xml/compat.c b/ext/xml/compat.c index 6bd69bec1961..18a7beaea2d3 100644 --- a/ext/xml/compat.c +++ b/ext/xml/compat.c @@ -473,13 +473,13 @@ XML_ParserCreate_MM(const XML_Char *encoding, const XML_Memory_Handling_Suite *m } php_libxml_sanitize_parse_ctxt_options(parser->parser); - xmlCtxtUseOptions(parser->parser, XML_PARSE_OLDSAX); + xmlCtxtUseOptions(parser->parser, XML_PARSE_OLDSAX | XML_PARSE_NOENT); - parser->parser->replaceEntities = 1; parser->parser->wellFormed = 0; if (sep != NULL) { + /* Note: sax2 flag will be set due to the magic number in `initialized` in php_xml_compat_handlers */ + ZEND_ASSERT(parser->parser->sax->initialized == XML_SAX2_MAGIC); parser->use_namespace = 1; - parser->parser->sax2 = 1; parser->_ns_separator = xmlStrdup(sep); } else { /* Reset flag as XML_SAX2_MAGIC is needed for xmlCreatePushParserCtxt @@ -565,10 +565,14 @@ XML_SetEndNamespaceDeclHandler(XML_Parser parser, XML_EndNamespaceDeclHandler en PHP_XML_API int XML_Parse(XML_Parser parser, const XML_Char *data, int data_len, int is_final) { - int error; + int error = xmlParseChunk(parser->parser, (char *) data, data_len, is_final); - error = xmlParseChunk(parser->parser, (char *) data, data_len, is_final); - return !error && parser->parser->lastError.level <= XML_ERR_WARNING; + if (!error) { + const xmlError *error_data = xmlCtxtGetLastError(parser->parser); + return !error_data || error_data->level <= XML_ERR_WARNING; + } + + return 0; } PHP_XML_API int From 688902d4553d9f483fd07a1343e419b705c77dad Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Tue, 2 Dec 2025 20:52:20 +0100 Subject: [PATCH 45/59] dom: Backport test for libxml changes --- ext/dom/tests/gh10234.phpt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/dom/tests/gh10234.phpt b/ext/dom/tests/gh10234.phpt index 5edc8fc6c1ff..11d39cd625a7 100644 --- a/ext/dom/tests/gh10234.phpt +++ b/ext/dom/tests/gh10234.phpt @@ -55,7 +55,7 @@ $document->documentElement->textContent = "quote 'test'"; var_dump($document->documentElement->textContent); var_dump($document->saveHTML()); ?> ---EXPECT-- +--EXPECTF-- -- Attribute tests -- string(38) " " @@ -67,10 +67,10 @@ string(13) "hello & world" string(50) " " string(9) "hi" -string(54) " +string(%d) "hi<\/b>")%r> " string(12) "quote "test"" -string(45) " +string(%d) " " string(12) "quote 'test'" string(45) " From 2b04e0831adc687a4a9666b9ec78fcdfd50c25af Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Tue, 2 Dec 2025 20:59:26 +0100 Subject: [PATCH 46/59] intl: Fix tests for icu update --- ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt | 4 ++-- ext/intl/tests/timezone_getDisplayName_variant4.phpt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt b/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt index be470d3d0d30..f434985cd08c 100644 --- a/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt +++ b/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt @@ -29,5 +29,5 @@ echo "msgf2: ", $msgf->format(array($time, 'date')), " ", */ ?> ---EXPECT-- -quinta-feira, 17 de maio de 2012 5:35:36 da tarde ptlis +--EXPECTF-- +quinta-feira, 17 de maio de 2012 5:35:36 %r(da tarde|p.m.)%r ptlis diff --git a/ext/intl/tests/timezone_getDisplayName_variant4.phpt b/ext/intl/tests/timezone_getDisplayName_variant4.phpt index 4bab07c744fa..d3e83d92a1a7 100644 --- a/ext/intl/tests/timezone_getDisplayName_variant4.phpt +++ b/ext/intl/tests/timezone_getDisplayName_variant4.phpt @@ -23,12 +23,12 @@ var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_COMMONLY_USED)) var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_GENERIC_LOCATION)); ?> ---EXPECT-- -string(3) "GMT" +--EXPECTF-- +string(%d) "%r(GMT|GMT\+0)%r" string(30) "Western European Standard Time" string(13) "Portugal Time" string(21) "Western European Time" string(5) "+0000" -string(3) "GMT" -string(3) "GMT" +string(%d) "%r(GMT|GMT\+00:00)%r" +string(%d) "%r(GMT|GMT\+0)%r" string(13) "Portugal Time" From cb413b5d5f96ad97a8cc2d4f0ad0b065051f122f Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 4 Dec 2025 14:31:29 +0100 Subject: [PATCH 47/59] Update clang in macOS build This resolves a crash in release builds. This may be dropped again in the future once the bugfix lands. Co-authored by Alexandre Daubois Co-authored by Arnaud Le Blanc Co-authored by Jakub Zelenka Closes GH-20669 --- .github/actions/macos-update-clang/action.yml | 17 +++++++++++++++++ .github/workflows/nightly.yml | 2 ++ .github/workflows/push.yml | 2 ++ 3 files changed, 21 insertions(+) create mode 100644 .github/actions/macos-update-clang/action.yml diff --git a/.github/actions/macos-update-clang/action.yml b/.github/actions/macos-update-clang/action.yml new file mode 100644 index 000000000000..bceb431aed5a --- /dev/null +++ b/.github/actions/macos-update-clang/action.yml @@ -0,0 +1,17 @@ +name: Update clang +runs: + using: composite + steps: + - shell: bash + run: | + softwareupdate -l + label=$((softwareupdate -l 2>/dev/null | grep 'Label:' | grep -o 'Command Line Tools for Xcode.*' | head -1) || echo '') + if [ -n "$label" ]; then + softwareupdate -i "$label" + xcode_path=$(ls -1 '/Applications' | grep 'Xcode_.*\.app' | head -1) + sudo xcode-select -s "/Applications/$xcode_path" + else + echo "Not found." + fi + which clang + clang -v diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 909a412e796e..e67deb8ffe4f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -367,6 +367,8 @@ jobs: uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} + - name: Update clang + uses: ./.github/actions/macos-update-clang - name: brew uses: ./.github/actions/brew - name: ./configure diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 028255330d1f..054f4a15286d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -117,6 +117,8 @@ jobs: steps: - name: git checkout uses: actions/checkout@v5 + - name: Update clang + uses: ./.github/actions/macos-update-clang - name: brew uses: ./.github/actions/brew - name: ccache From 6cdb8bf0a29921f8a5630f72d885dcf9c5a450b6 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Sat, 13 Dec 2025 20:27:14 +0100 Subject: [PATCH 48/59] Fix xcode-select The old Xcode sticks around, so make sure we sort in reverse to pick the newer version. Technically we should use something like sort -Vr, but -V doesn't exist on macOS. But that won't be a problem until Xcode 100, which my great great grand children can worry about. --- .github/actions/macos-update-clang/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/macos-update-clang/action.yml b/.github/actions/macos-update-clang/action.yml index bceb431aed5a..916b4dfe41f4 100644 --- a/.github/actions/macos-update-clang/action.yml +++ b/.github/actions/macos-update-clang/action.yml @@ -8,7 +8,7 @@ runs: label=$((softwareupdate -l 2>/dev/null | grep 'Label:' | grep -o 'Command Line Tools for Xcode.*' | head -1) || echo '') if [ -n "$label" ]; then softwareupdate -i "$label" - xcode_path=$(ls -1 '/Applications' | grep 'Xcode_.*\.app' | head -1) + xcode_path=$(ls -1 '/Applications' | grep 'Xcode_.*\.app' | sort -r | head -1) sudo xcode-select -s "/Applications/$xcode_path" else echo "Not found." From 5850c7de7c5032a84edbde17360de3ddc00fce57 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 21 Feb 2023 16:50:31 +0100 Subject: [PATCH 49/59] sapi/fpm: remove use of variable-length arrays (#10645) According to @cmb69, PHP does not require VLA support (https://github.com/php/php-src/pull/10304#discussion_r1069343092). VLAs are a bad idea for several reasons, so let's get rid of them. Two of the VLAs were probably unintended; unlike C++, C doesn't have the concept of "constant expressions", so an array with a "const" length is technically still a VLA. This is fixed by removing the "const" variable, and using sizeof() instead. (cherry picked from commit ff2a211d55650201e5bbe370c319a0c913613eb9) --- sapi/fpm/fpm/fpm_php_trace.c | 11 +++++------ sapi/fpm/fpm/fpm_stdio.c | 5 ++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/sapi/fpm/fpm/fpm_php_trace.c b/sapi/fpm/fpm/fpm_php_trace.c index 0e1d8e3f6cee..b1535b26e3ef 100644 --- a/sapi/fpm/fpm/fpm_php_trace.c +++ b/sapi/fpm/fpm/fpm_php_trace.c @@ -39,15 +39,14 @@ static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog) /* {{{ * int callers_limit = child->wp->config->request_slowlog_trace_depth; pid_t pid = child->pid; struct timeval tv; - static const int buf_size = 1024; - char buf[buf_size]; + char buf[1024]; long execute_data; long path_translated; long l; gettimeofday(&tv, 0); - zlog_print_time(&tv, buf, buf_size); + zlog_print_time(&tv, buf, sizeof(buf)); fprintf(slowlog, "\n%s [pool %s] pid %d\n", buf, child->wp->config->name, (int) pid); @@ -57,7 +56,7 @@ static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog) /* {{{ * path_translated = l; - if (0 > fpm_trace_get_strz(buf, buf_size, path_translated)) { + if (0 > fpm_trace_get_strz(buf, sizeof(buf), path_translated)) { return -1; } @@ -103,7 +102,7 @@ static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog) /* {{{ * ZEND_UNREACHABLE(); } } else { - if (0 > fpm_trace_get_strz(buf, buf_size, function_name + offsetof(zend_string, val))) { + if (0 > fpm_trace_get_strz(buf, sizeof(buf), function_name + offsetof(zend_string, val))) { return -1; } @@ -149,7 +148,7 @@ static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog) /* {{{ * file_name = l; - if (0 > fpm_trace_get_strz(buf, buf_size, file_name + offsetof(zend_string, val))) { + if (0 > fpm_trace_get_strz(buf, sizeof(buf), file_name + offsetof(zend_string, val))) { return -1; } diff --git a/sapi/fpm/fpm/fpm_stdio.c b/sapi/fpm/fpm/fpm_stdio.c index dec540d17aca..c104ff987f0c 100644 --- a/sapi/fpm/fpm/fpm_stdio.c +++ b/sapi/fpm/fpm/fpm_stdio.c @@ -168,9 +168,8 @@ int fpm_stdio_flush_child(void) static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg) /* {{{ */ { - static const int max_buf_size = 1024; int fd = ev->fd; - char buf[max_buf_size]; + char buf[1024]; struct fpm_child_s *child; int is_stdout; struct fpm_event_s *event; @@ -216,7 +215,7 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg) while (1) { stdio_read: - in_buf = read(fd, buf, max_buf_size - 1); + in_buf = read(fd, buf, sizeof(buf) - 1); if (in_buf <= 0) { /* no data */ if (in_buf == 0 || !PHP_IS_TRANSIENT_ERROR(errno)) { /* pipe is closed or error */ From 2bf2411976951c5a316e2c1c3e6e8a6ef85729dc Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 25 Oct 2025 11:15:34 +0200 Subject: [PATCH 50/59] Make bug70417.phpt less flaky Closes GH-20287. (cherry picked from commit ed9529a7d3c1f5dfbf16c2d388d944af8ec86a76) --- ext/phar/tests/tar/bug70417.phpt | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/ext/phar/tests/tar/bug70417.phpt b/ext/phar/tests/tar/bug70417.phpt index 4d98a18954cc..504d7e1e387b 100644 --- a/ext/phar/tests/tar/bug70417.phpt +++ b/ext/phar/tests/tar/bug70417.phpt @@ -3,32 +3,17 @@ Bug #70417 (PharData::compress() doesn't close temp file) --EXTENSIONS-- phar zlib ---SKIPIF-- - --FILE-- /dev/null', $out); // Note: valgrind can produce false positives for /usr/bin/lsof - return count($out); -} $filename = __DIR__ . '/bug70417.tar'; @unlink("$filename.gz"); -$openFiles1 = countOpenFiles(); +$resBefore = count(get_resources()); $arch = new PharData($filename); $arch->addFromString('foo', 'bar'); $arch->compress(Phar::GZ); unset($arch); -$openFiles2 = countOpenFiles(); -var_dump($openFiles1 === $openFiles2); +$resAfter = count(get_resources()); +var_dump($resBefore === $resAfter); ?> --CLEAN-- Date: Tue, 25 Nov 2025 23:11:38 +0100 Subject: [PATCH 51/59] Fix GH-20584: Information Leak of Memory The string added had uninitialized memory due to php_read_stream_all_chunks() not moving the buffer position, resulting in the same data always being overwritten instead of new data being added to the end of the buffer. This is backport as there is a security impact as described in GHSA-3237-qqm7-mfv7 . --- ext/standard/image.c | 1 + ext/standard/tests/image/gh20584.phpt | 39 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 ext/standard/tests/image/gh20584.phpt diff --git a/ext/standard/image.c b/ext/standard/image.c index 5200295f3af2..269117318c4b 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -434,6 +434,7 @@ static size_t php_read_stream_all_chunks(php_stream *stream, char *buffer, size_ if (read_now < stream->chunk_size && read_total != length) { return 0; } + buffer += read_now; } while (read_total < length); return read_total; diff --git a/ext/standard/tests/image/gh20584.phpt b/ext/standard/tests/image/gh20584.phpt new file mode 100644 index 000000000000..d117f2182026 --- /dev/null +++ b/ext/standard/tests/image/gh20584.phpt @@ -0,0 +1,39 @@ +--TEST-- +GH-20584 (Information Leak of Memory) +--CREDITS-- +Nikita Sveshnikov (Positive Technologies) +--FILE-- + +--CLEAN-- + +--EXPECT-- +bool(true) From 727a4ddc39ca9b78131e06b5537fe8b6c3dd6fe7 Mon Sep 17 00:00:00 2001 From: Jakub Zelenka Date: Sat, 11 Oct 2025 19:37:26 +0200 Subject: [PATCH 52/59] Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref --- ext/pdo/pdo_sql_parser.re | 6 +++++ ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.phpt | 28 ++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.phpt diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index 6bb0837fb31f..7f4721d12a63 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -287,6 +287,12 @@ safe: } plc->quoted = stmt->dbh->methods->quoter(stmt->dbh, buf, param_type); + if (plc->quoted == NULL) { + /* bork */ + ret = -1; + strncpy(stmt->error_code, stmt->dbh->error_code, 6); + goto clean_up; + } } } diff --git a/ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.phpt b/ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.phpt new file mode 100644 index 000000000000..736354cab13c --- /dev/null +++ b/ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.phpt @@ -0,0 +1,28 @@ +--TEST-- +#GHSA-8xr5-qppj-gvwj: NULL Pointer Derefernce for failed user input quoting +--EXTENSIONS-- +pdo +pdo_pgsql +--SKIPIF-- + +--FILE-- +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); + +$sql = "SELECT * FROM users where username = :username"; +$stmt = $db->prepare($sql); + +$p1 = "alice\x99"; +var_dump($stmt->execute(['username' => $p1])); + +?> +--EXPECT-- +bool(false) From 8b801151bd54b36aae4593ed6cfc096e8122b415 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Sun, 9 Nov 2025 13:23:11 +0100 Subject: [PATCH 53/59] Fix GHSA-h96m-rvf9-jgm2 --- ext/standard/array.c | 7 ++++++- .../tests/array/GHSA-h96m-rvf9-jgm2.phpt | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/array/GHSA-h96m-rvf9-jgm2.phpt diff --git a/ext/standard/array.c b/ext/standard/array.c index 86d70a8844e3..e3474c7c8fda 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -3771,7 +3771,7 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET int argc, i; zval *src_entry; HashTable *src, *dest; - uint32_t count = 0; + uint64_t count = 0; ZEND_PARSE_PARAMETERS_START(0, -1) Z_PARAM_VARIADIC('+', args, argc) @@ -3791,6 +3791,11 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET count += zend_hash_num_elements(Z_ARRVAL_P(arg)); } + if (UNEXPECTED(count >= HT_MAX_SIZE)) { + zend_throw_error(NULL, "The total number of elements must be lower than %u", HT_MAX_SIZE); + RETURN_THROWS(); + } + if (argc == 2) { zval *ret = NULL; diff --git a/ext/standard/tests/array/GHSA-h96m-rvf9-jgm2.phpt b/ext/standard/tests/array/GHSA-h96m-rvf9-jgm2.phpt new file mode 100644 index 000000000000..2e3e85357e13 --- /dev/null +++ b/ext/standard/tests/array/GHSA-h96m-rvf9-jgm2.phpt @@ -0,0 +1,16 @@ +--TEST-- +GHSA-h96m-rvf9-jgm2 +--FILE-- +getMessage(), "\n"; +} + +?> +--EXPECTF-- +The total number of elements must be lower than %d From ed70b1ea43a9b7ffa2f53b3e5d6ba403f37ae81c Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 6 Sep 2025 21:55:13 +0200 Subject: [PATCH 54/59] Fix GHSA-www2-q4fc-65wf --- ext/standard/basic_functions.c | 12 ++-- ext/standard/dns.c | 6 +- ext/standard/dns_win32.c | 6 +- .../tests/network/ghsa-www2-q4fc-65wf.phpt | 62 +++++++++++++++++++ 4 files changed, 74 insertions(+), 12 deletions(-) create mode 100644 ext/standard/tests/network/ghsa-www2-q4fc-65wf.phpt diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index ddaf1368410b..18db1604678c 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -638,7 +638,7 @@ PHP_FUNCTION(inet_pton) char buffer[17]; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(address, address_len) + Z_PARAM_PATH(address, address_len) ZEND_PARSE_PARAMETERS_END(); memset(buffer, 0, sizeof(buffer)); @@ -675,7 +675,7 @@ PHP_FUNCTION(ip2long) #endif ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(addr, addr_len) + Z_PARAM_PATH(addr, addr_len) ZEND_PARSE_PARAMETERS_END(); #ifdef HAVE_INET_PTON @@ -2249,8 +2249,8 @@ PHP_FUNCTION(getservbyname) struct servent *serv; ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_STRING(proto, proto_len) + Z_PARAM_PATH_STR(name) + Z_PARAM_PATH(proto, proto_len) ZEND_PARSE_PARAMETERS_END(); @@ -2293,7 +2293,7 @@ PHP_FUNCTION(getservbyport) ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_LONG(port) - Z_PARAM_STRING(proto, proto_len) + Z_PARAM_PATH(proto, proto_len) ZEND_PARSE_PARAMETERS_END(); serv = getservbyport(htons((unsigned short) port), proto); @@ -2316,7 +2316,7 @@ PHP_FUNCTION(getprotobyname) struct protoent *ent; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(name, name_len) + Z_PARAM_PATH(name, name_len) ZEND_PARSE_PARAMETERS_END(); ent = getprotobyname(name); diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 6d22e644a8ef..73a60f2a8259 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -399,7 +399,7 @@ PHP_FUNCTION(dns_check_record) #endif ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STRING(hostname, hostname_len) + Z_PARAM_PATH(hostname, hostname_len) Z_PARAM_OPTIONAL Z_PARAM_STR(rectype) ZEND_PARSE_PARAMETERS_END(); @@ -846,7 +846,7 @@ PHP_FUNCTION(dns_get_record) bool raw = 0; ZEND_PARSE_PARAMETERS_START(1, 5) - Z_PARAM_STRING(hostname, hostname_len) + Z_PARAM_PATH(hostname, hostname_len) Z_PARAM_OPTIONAL Z_PARAM_LONG(type_param) Z_PARAM_ZVAL(authns) @@ -1084,7 +1084,7 @@ PHP_FUNCTION(dns_get_mx) #endif ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STRING(hostname, hostname_len) + Z_PARAM_PATH(hostname, hostname_len) Z_PARAM_ZVAL(mx_list) Z_PARAM_OPTIONAL Z_PARAM_ZVAL(weight_list) diff --git a/ext/standard/dns_win32.c b/ext/standard/dns_win32.c index bef90cd61f28..0302b8542a0d 100644 --- a/ext/standard/dns_win32.c +++ b/ext/standard/dns_win32.c @@ -48,7 +48,7 @@ PHP_FUNCTION(dns_get_mx) /* {{{ */ DNS_STATUS status; /* Return value of DnsQuery_A() function */ PDNS_RECORD pResult, pRec; /* Pointer to DNS_RECORD structure */ - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz|z", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pz|z", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) { RETURN_THROWS(); } @@ -102,7 +102,7 @@ PHP_FUNCTION(dns_check_record) DNS_STATUS status; /* Return value of DnsQuery_A() function */ PDNS_RECORD pResult; /* Pointer to DNS_RECORD structure */ - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|S", &hostname, &hostname_len, &rectype) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|S", &hostname, &hostname_len, &rectype) == FAILURE) { RETURN_THROWS(); } @@ -354,7 +354,7 @@ PHP_FUNCTION(dns_get_record) int type, type_to_fetch, first_query = 1, store_results = 1; bool raw = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lz!z!b", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|lz!z!b", &hostname, &hostname_len, &type_param, &authns, &addtl, &raw) == FAILURE) { RETURN_THROWS(); } diff --git a/ext/standard/tests/network/ghsa-www2-q4fc-65wf.phpt b/ext/standard/tests/network/ghsa-www2-q4fc-65wf.phpt new file mode 100644 index 000000000000..3d082c8e9522 --- /dev/null +++ b/ext/standard/tests/network/ghsa-www2-q4fc-65wf.phpt @@ -0,0 +1,62 @@ +--TEST-- +GHSA-www2-q4fc-65wf +--DESCRIPTION-- +This is a ZPP test but *keep* this as it is security-sensitive! +--FILE-- +getMessage(), "\n"; +} +try { + dns_get_mx("\0", $out); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + dns_get_record("\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + getprotobyname("\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + getservbyname("\0", "tcp"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + getservbyname("x", "tcp\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + getservbyport(0, "tcp\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + inet_pton("\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + ip2long("\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +?> +--EXPECT-- +dns_check_record(): Argument #1 ($hostname) must not contain any null bytes +dns_get_mx(): Argument #1 ($hostname) must not contain any null bytes +dns_get_record(): Argument #1 ($hostname) must not contain any null bytes +getprotobyname(): Argument #1 ($protocol) must not contain any null bytes +getservbyname(): Argument #1 ($service) must not contain any null bytes +getservbyname(): Argument #2 ($protocol) must not contain any null bytes +getservbyport(): Argument #2 ($protocol) must not contain any null bytes +inet_pton(): Argument #1 ($ip) must not contain any null bytes +ip2long(): Argument #1 ($ip) must not contain any null bytes From c48a9f42d336dc22e72141775022f4588ab4b2dd Mon Sep 17 00:00:00 2001 From: Jakub Zelenka Date: Fri, 12 Dec 2025 13:49:02 +0100 Subject: [PATCH 55/59] Update NEWS with info about security issues --- NEWS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NEWS b/NEWS index 998b5d97d635..6ac638073fae 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,18 @@ PHP NEWS . Reset global pointers to prevent use-after-free in zend_jit_status(). (Florian Engelhardt) +- PDO: + . Fixed GHSA-8xr5-qppj-gvwj (PDO quoting result null deref). (CVE-2025-14180) + (Jakub Zelenka) + +- Standard: + . Fixed GHSA-www2-q4fc-65wf (Null byte termination in dns_get_record()). + (ndossche) + . Fixed GHSA-h96m-rvf9-jgm2 (Heap buffer overflow in array_merge()). + (CVE-2025-14178) (ndossche) + . Fixed GHSA-3237-qqm7-mfv7 (Information Leak of Memory in getimagesize). + (CVE-2025-14177) (ndossche) + 03 Jul 2025, PHP 8.1.33 - PGSQL: From bb70c5589ab76399e5b090200dc1a485014ac3a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 17 Dec 2025 13:58:51 +0100 Subject: [PATCH 56/59] Update GitHub Action workflows to `actions/checkout@v6` Keep this up to date in all nonbranches, because the node.js runtime for older versions might get deprecated in the future and fixing this for all branches at once is easier. see 2650248a927224aa5b76130d406a691ad774fd38 --- .github/workflows/nightly.yml | 38 +++++++++++++++++------------------ .github/workflows/push.yml | 8 ++++---- .github/workflows/root.yml | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e67deb8ffe4f..00e2cbb43c23 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -57,7 +57,7 @@ jobs: runs-on: [self-hosted, gentoo, ppc64] steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: System info @@ -98,7 +98,7 @@ jobs: image: 'alpine:3.22' steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: apk @@ -200,7 +200,7 @@ jobs: runs-on: ubuntu-${{ matrix.asan && inputs.asan_ubuntu_version || inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: Create MSSQL container @@ -298,7 +298,7 @@ jobs: FIREBIRD_PASSWORD: test steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: apt @@ -364,7 +364,7 @@ jobs: runs-on: macos-${{ matrix.os }} steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: Update clang @@ -439,7 +439,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: Create MSSQL container @@ -488,7 +488,7 @@ jobs: USE_TRACKED_ALLOC: 1 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: apt @@ -688,7 +688,7 @@ jobs: runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: Create MSSQL container @@ -751,7 +751,7 @@ jobs: runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: apt @@ -838,7 +838,7 @@ jobs: runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: apt @@ -883,38 +883,38 @@ jobs: CXX: ccache g++ steps: - name: git checkout PHP - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: path: php ref: ${{ inputs.branch }} - name: git checkout apcu - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: krakjoe/apcu path: apcu - name: git checkout imagick - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: Imagick/imagick path: imagick - name: git checkout memcached - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: php-memcached-dev/php-memcached path: memcached - name: git checkout redis - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: phpredis/phpredis path: redis - name: git checkout xdebug if: false - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: xdebug/xdebug path: xdebug - name: git checkout yaml - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: php/pecl-file_formats-yaml path: yaml @@ -1019,7 +1019,7 @@ jobs: - name: git config run: git config --global core.autocrlf false && git config --global core.eol lf - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: Setup @@ -1040,7 +1040,7 @@ jobs: timeout-minutes: 50 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: FreeBSD diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 054f4a15286d..bedf186bfefe 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -71,7 +71,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Create MSSQL container uses: ./.github/actions/setup-mssql - name: Create Oracle container @@ -116,7 +116,7 @@ jobs: runs-on: macos-14 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Update clang uses: ./.github/actions/macos-update-clang - name: brew @@ -165,7 +165,7 @@ jobs: - name: git config run: git config --global core.autocrlf false && git config --global core.eol lf - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Setup uses: ./.github/actions/setup-windows - name: Build @@ -179,6 +179,6 @@ jobs: timeout-minutes: 50 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: FreeBSD uses: ./.github/actions/freebsd diff --git a/.github/workflows/root.yml b/.github/workflows/root.yml index ea23349fd692..68e43772d89c 100644 --- a/.github/workflows/root.yml +++ b/.github/workflows/root.yml @@ -13,7 +13,7 @@ jobs: outputs: branches: ${{ steps.set-matrix.outputs.branches }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: # Set fetch-depth to 0 to clone the full repository # including all branches. This is required to find From 6f61244a03e5a1b0de70181de627296e28287eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 17 Dec 2025 14:00:56 +0100 Subject: [PATCH 57/59] Update GitHub Action workflows to `actions/cache@v5` Keep this up to date in all nonbranches, because the node.js runtime for older versions might get deprecated in the future and fixing this for all branches at once is easier. see 2650248a927224aa5b76130d406a691ad774fd38 --- .github/workflows/root.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/root.yml b/.github/workflows/root.yml index 68e43772d89c..55bfe2ebeb9f 100644 --- a/.github/workflows/root.yml +++ b/.github/workflows/root.yml @@ -20,7 +20,7 @@ jobs: # the correct commit hashes. fetch-depth: 0 - name: Grab the commit mapping - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: branch-commit-cache.json # The cache key needs to change every time for the From 6f82565f12630ba320c52c96e28160189b15ecbf Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Wed, 31 Dec 2025 16:58:52 -0600 Subject: [PATCH 58/59] PHP 8.1 is now end-of-life --- NEWS | 2 +- Zend/zend.h | 2 +- configure.ac | 2 +- main/php_version.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 6ac638073fae..9d420d24da63 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? ????, PHP 8.1.34 +18 Dec 2025, PHP 8.1.34 - Curl: . Fix curl build and test failures with version 8.16. diff --git a/Zend/zend.h b/Zend/zend.h index 29bb98c85fca..463a829faff2 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -20,7 +20,7 @@ #ifndef ZEND_H #define ZEND_H -#define ZEND_VERSION "4.1.34-dev" +#define ZEND_VERSION "4.1.34" #define ZEND_ENGINE_3 diff --git a/configure.ac b/configure.ac index 51256f6b7c17..c0defea03b73 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ dnl Basic autoconf initialization, generation of config.nice. dnl ---------------------------------------------------------------------------- AC_PREREQ([2.68]) -AC_INIT([PHP],[8.1.34-dev],[https://github.com/php/php-src/issues],[php],[https://www.php.net]) +AC_INIT([PHP],[8.1.34],[https://github.com/php/php-src/issues],[php],[https://www.php.net]) AC_CONFIG_SRCDIR([main/php_version.h]) AC_CONFIG_AUX_DIR([build]) AC_PRESERVE_HELP_ORDER diff --git a/main/php_version.h b/main/php_version.h index 96bd615c0738..36a5619c8d26 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -3,6 +3,6 @@ #define PHP_MAJOR_VERSION 8 #define PHP_MINOR_VERSION 1 #define PHP_RELEASE_VERSION 34 -#define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "8.1.34-dev" +#define PHP_EXTRA_VERSION "" +#define PHP_VERSION "8.1.34" #define PHP_VERSION_ID 80134 From 1d7dec178a094e6e75b229ce22754045f8c6070a Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Sun, 18 Oct 2026 20:12:35 +0200 Subject: [PATCH 59/59] Avoid state corruption via bailout Minimal mitigation for EOL version. Fix GHSA-w8hw-w9fx-j79w (CVE-2026-109618) Fix GHSA-6wmf-4rv5-p3rp (CVE-2026-109619) Co-authored-by: Ilija Tovilo --- Zend/zend_API.h | 1 + Zend/zend_alloc.c | 68 +++++++++----- Zend/zend_alloc.h | 2 + Zend/zend_execute_API.c | 15 ++++ Zend/zend_hash.c | 13 ++- Zend/zend_hash.h | 1 + Zend/zend_multiply.h | 4 +- Zend/zend_strtod.c | 4 +- Zend/zend_types.h | 26 +++--- Zend/zend_vm_def.h | 11 ++- Zend/zend_vm_execute.h | 94 ++++++++++++++++++-- ext/opcache/ZendAccelerator.c | 5 ++ ext/opcache/ZendAccelerator.h | 11 ++- ext/opcache/zend_file_cache.c | 8 ++ ext/opcache/zend_persist.c | 67 ++++++++++++-- ext/session/session.c | 2 +- ext/zend_test/tests/observer_bug81430_2.phpt | 2 - ext/zend_test/tests/observer_bug81435.phpt | 1 - ext/zend_test/tests/observer_error_01.phpt | 2 - main/SAPI.c | 5 ++ main/main.c | 6 ++ main/php_variables.c | 8 +- main/rfc1867.c | 28 ++++-- 23 files changed, 311 insertions(+), 73 deletions(-) diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 9ed1a3fbabd2..a32b83c0533d 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -490,6 +490,7 @@ ZEND_API const char *zend_get_type_by_const(int type); #define array_init(arg) ZVAL_ARR((arg), zend_new_array(0)) #define array_init_size(arg, size) ZVAL_ARR((arg), zend_new_array(size)) +#define array_init_singleton(arg) ZVAL_ARR((arg), zend_new_array_singleton()) ZEND_API void object_init(zval *arg); ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *ce); ZEND_API zend_result object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties); diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 61792b37c9c5..7f43a7f6df07 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -57,6 +57,7 @@ #include "zend_operators.h" #include "zend_multiply.h" #include "zend_bitset.h" +#include "zend_execute.h" #include #ifdef HAVE_UNISTD_H @@ -364,7 +365,42 @@ static ZEND_COLD ZEND_NORETURN void zend_mm_panic(const char *message) #if ZEND_DEBUG && defined(HAVE_KILL) && defined(HAVE_GETPID) kill(getpid(), SIGSEGV); #endif - exit(1); + _exit(1); +} + +ZEND_API ZEND_COLD ZEND_NORETURN void zend_mm_safe_error_ex(const char *format, ...) +{ + zend_string *script_filename = NULL; + uint32_t script_lineno = 0; + + if (zend_is_executing()) { + script_filename = zend_get_executed_filename_ex(); + script_lineno = zend_get_executed_lineno(); + } else if (zend_is_compiling()) { + script_filename = zend_get_compiled_filename(); + script_lineno = zend_get_compiled_lineno(); + } + + va_list args; + va_start(args, format); + + char buf[1024]; + vsnprintf(buf, sizeof(buf), format, args); + + va_end(args); + + fprintf(stderr, + "\nFatal error: %s in %s on line %d\n", + buf, + script_filename ? ZSTR_VAL(script_filename) : "Unknown", + script_lineno); + + /* See http://support.microsoft.com/kb/190351 */ +# ifdef ZEND_WIN32 + fflush(stderr); +# endif + + _exit(1); } static ZEND_COLD ZEND_NORETURN void zend_mm_safe_error(zend_mm_heap *heap, @@ -376,22 +412,14 @@ static ZEND_COLD ZEND_NORETURN void zend_mm_safe_error(zend_mm_heap *heap, #endif size_t size) { + (void) heap; - heap->overflow = 1; - zend_try { - zend_error_noreturn(E_ERROR, - format, - limit, + zend_mm_safe_error_ex(format, limit, #if ZEND_DEBUG - filename, - lineno, + filename, + lineno, #endif - size); - } zend_catch { - } zend_end_try(); - heap->overflow = 0; - zend_bailout(); - exit(1); + size); } #ifdef _WIN32 @@ -1356,7 +1384,7 @@ static zend_always_inline void *zend_mm_alloc_heap(zend_mm_heap *heap, size_t si size = MAX(size, 1); size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info)); if (UNEXPECTED(size < real_size)) { - zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu + %zu)", ZEND_MM_ALIGNED_SIZE(real_size), ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info))); + zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%zu + %zu)", ZEND_MM_ALIGNED_SIZE(real_size), ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info))); return NULL; } #endif @@ -1800,7 +1828,7 @@ static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D void *ptr; if (UNEXPECTED(new_size < size)) { - zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu + %zu)", size, alignment); + zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%zu + %zu)", size, alignment); } #if ZEND_MM_LIMIT @@ -2660,7 +2688,7 @@ ZEND_API char* ZEND_FASTCALL _estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_ length = strlen(s); if (UNEXPECTED(length + 1 == 0)) { - zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (1 * %zu + 1)", length); + zend_mm_safe_error_ex("Possible integer overflow in memory allocation (1 * %zu + 1)", length); } p = (char *) _emalloc(length + 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); memcpy(p, s, length+1); @@ -2672,7 +2700,7 @@ ZEND_API char* ZEND_FASTCALL _estrndup(const char *s, size_t length ZEND_FILE_LI char *p; if (UNEXPECTED(length + 1 == 0)) { - zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (1 * %zu + 1)", length); + zend_mm_safe_error_ex("Possible integer overflow in memory allocation (1 * %zu + 1)", length); } p = (char *) _emalloc(length + 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); memcpy(p, s, length); @@ -2686,7 +2714,7 @@ ZEND_API char* ZEND_FASTCALL zend_strndup(const char *s, size_t length) char *p; if (UNEXPECTED(length + 1 == 0)) { - zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (1 * %zu + 1)", length); + zend_mm_safe_error_ex("Possible integer overflow in memory allocation (1 * %zu + 1)", length); } p = (char *) malloc(length + 1); if (UNEXPECTED(p == NULL)) { @@ -3084,7 +3112,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void static ZEND_COLD ZEND_NORETURN void zend_out_of_memory(void) { fprintf(stderr, "Out of memory\n"); - exit(1); + _exit(1); } ZEND_API void * __zend_malloc(size_t len) diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h index 9603af8a27d3..72becadc7746 100644 --- a/Zend/zend_alloc.h +++ b/Zend/zend_alloc.h @@ -403,6 +403,8 @@ static void apc_init_heap(void) size_t zend_mm_globals_size(void); #endif +ZEND_API ZEND_COLD ZEND_NORETURN void zend_mm_safe_error_ex(const char *format, ...); + END_EXTERN_C() #endif diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 1e31934f1581..82cea225a8ed 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -385,6 +385,12 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown) #endif } else { zend_hash_discard(EG(zend_constants), EG(persistent_constants_count)); + /* may be used by zend_error_zstr_at before init_executor */ + ZVAL_UNDEF(&EG(user_error_handler)); + ZVAL_UNDEF(&EG(user_exception_handler)); + memset(&EG(user_error_handlers_error_reporting), 0, sizeof(EG(user_error_handlers_error_reporting))); + memset(&EG(user_error_handlers), 0, sizeof(EG(user_error_handlers))); + memset(&EG(user_exception_handlers), 0, sizeof(EG(user_exception_handlers))); } zend_objects_store_free_object_storage(&EG(objects_store), fast_shutdown); @@ -406,6 +412,13 @@ void shutdown_executor(void) /* {{{ */ zend_shutdown_executor_values(fast_shutdown); + /* may be used by zend_error_zstr_at before init_executor */ + EG(record_errors) = false; + EG(num_errors) = 0; + EG(errors) = NULL; + EG(error_handling) = EH_NORMAL; + EG(exception) = NULL; + zend_weakrefs_shutdown(); zend_max_execution_timer_shutdown(); zend_fiber_shutdown(); @@ -422,6 +435,8 @@ void shutdown_executor(void) /* {{{ */ */ zend_hash_discard(EG(function_table), EG(persistent_functions_count)); zend_hash_discard(EG(class_table), EG(persistent_classes_count)); + EG(objects_store).object_buckets = NULL; + EG(objects_store).top = 1; } else { zend_vm_stack_destroy(); diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index b96a95110117..65f31c2b9a21 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -119,7 +119,7 @@ static zend_always_inline uint32_t zend_hash_check_size(uint32_t nSize) if (nSize <= HT_MIN_SIZE) { return HT_MIN_SIZE; } else if (UNEXPECTED(nSize >= HT_MAX_SIZE)) { - zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%u * %zu + %zu)", nSize, sizeof(Bucket), sizeof(Bucket)); + zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%u * %zu + %zu)", nSize, sizeof(Bucket), sizeof(Bucket)); } #ifdef ZEND_WIN32 @@ -276,6 +276,13 @@ ZEND_API HashTable* ZEND_FASTCALL _zend_new_array_0(void) return ht; } +ZEND_API HashTable* ZEND_FASTCALL zend_new_array_singleton(void) +{ + HashTable *ht = _zend_new_array_0(); + ht->nTableSize = 1; + return ht; +} + ZEND_API HashTable* ZEND_FASTCALL _zend_new_array(uint32_t nSize) { HashTable *ht = emalloc(sizeof(HashTable)); @@ -307,7 +314,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_packed_grow(HashTable *ht) { HT_ASSERT_RC1(ht); if (ht->nTableSize >= HT_MAX_SIZE) { - zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket), sizeof(Bucket)); + zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket), sizeof(Bucket)); } uint32_t newTableSize = ht->nTableSize * 2; HT_SET_DATA_ADDR(ht, perealloc2(HT_GET_DATA_ADDR(ht), HT_SIZE_EX(newTableSize, HT_MIN_MASK), HT_USED_SIZE(ht), GC_FLAGS(ht) & IS_ARRAY_PERSISTENT)); @@ -1233,7 +1240,7 @@ static void ZEND_FASTCALL zend_hash_do_resize(HashTable *ht) pefree(old_data, GC_FLAGS(ht) & IS_ARRAY_PERSISTENT); zend_hash_rehash(ht); } else { - zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket) + sizeof(uint32_t), sizeof(Bucket)); + zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket) + sizeof(uint32_t), sizeof(Bucket)); } } diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 092682d67713..09a7994d91d5 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -314,6 +314,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_rehash(HashTable *ht); #endif ZEND_API HashTable* ZEND_FASTCALL _zend_new_array_0(void); +ZEND_API HashTable* ZEND_FASTCALL zend_new_array_singleton(void); ZEND_API HashTable* ZEND_FASTCALL _zend_new_array(uint32_t size); ZEND_API HashTable* ZEND_FASTCALL zend_new_pair(zval *val1, zval *val2); ZEND_API uint32_t zend_array_count(HashTable *ht); diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index c6cd472a237b..bfe1b8e88692 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -321,7 +321,7 @@ static zend_always_inline size_t zend_safe_address_guarded(size_t nmemb, size_t size_t ret = zend_safe_address(nmemb, size, offset, &overflow); if (UNEXPECTED(overflow)) { - zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset); + zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset); return 0; } return ret; @@ -334,7 +334,7 @@ static zend_always_inline size_t zend_safe_addmult(size_t nmemb, size_t size, si size_t ret = zend_safe_address(nmemb, size, offset, &overflow); if (UNEXPECTED(overflow)) { - zend_error_noreturn(E_ERROR, "Possible integer overflow in %s (%zu * %zu + %zu)", message, nmemb, size, offset); + zend_mm_safe_error_ex("Possible integer overflow in %s (%zu * %zu + %zu)", message, nmemb, size, offset); return 0; } return ret; diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c index 3e7f90378ef5..7f72c82f610e 100644 --- a/Zend/zend_strtod.c +++ b/Zend/zend_strtod.c @@ -593,7 +593,7 @@ Balloc rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong)); if (!rv) { FREE_DTOA_LOCK(0); - zend_error_noreturn(E_ERROR, "Balloc() failed to allocate memory"); + zend_mm_safe_error_ex("Balloc() failed to allocate memory"); } #else len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) @@ -606,7 +606,7 @@ Balloc rv = (Bigint*)MALLOC(len*sizeof(double)); if (!rv) { FREE_DTOA_LOCK(0); - zend_error_noreturn(E_ERROR, "Balloc() failed to allocate memory"); + zend_mm_safe_error_ex("Balloc() failed to allocate memory"); } #endif rv->k = k; diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 5bc47dd31934..ab28b0fa163b 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -448,17 +448,21 @@ struct _zend_array { # define HT_HASH_RESET(ht) do { \ char *p = (char*)&HT_HASH(ht, (ht)->nTableMask); \ size_t size = HT_HASH_SIZE((ht)->nTableMask); \ - __m128i xmm0 = _mm_setzero_si128(); \ - xmm0 = _mm_cmpeq_epi8(xmm0, xmm0); \ - ZEND_ASSERT(size >= 64 && ((size & 0x3f) == 0)); \ - do { \ - _mm_storeu_si128((__m128i*)p, xmm0); \ - _mm_storeu_si128((__m128i*)(p+16), xmm0); \ - _mm_storeu_si128((__m128i*)(p+32), xmm0); \ - _mm_storeu_si128((__m128i*)(p+48), xmm0); \ - p += 64; \ - size -= 64; \ - } while (size != 0); \ + if (UNEXPECTED(size < 64)) { \ + memset(p, HT_INVALID_IDX, size); \ + } else { \ + __m128i xmm0 = _mm_setzero_si128(); \ + xmm0 = _mm_cmpeq_epi8(xmm0, xmm0); \ + ZEND_ASSERT(size >= 64 && ((size & 0x3f) == 0)); \ + do { \ + _mm_storeu_si128((__m128i*)p, xmm0); \ + _mm_storeu_si128((__m128i*)(p+16), xmm0); \ + _mm_storeu_si128((__m128i*)(p+32), xmm0); \ + _mm_storeu_si128((__m128i*)(p+48), xmm0); \ + p += 64; \ + size -= 64; \ + } while (size != 0); \ + } \ } while (0) #else # define HT_HASH_RESET(ht) \ diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index a6f86a9eab6f..ad893ebfb5c6 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -408,7 +408,7 @@ ZEND_VM_HANDLER(8, ZEND_CONCAT, CONST|TMPVAR|CV, CONST|TMPVAR|CV, SPEC(NO_CONST_ size_t len = ZSTR_LEN(op1_str); if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { - zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation"); + zend_mm_safe_error_ex("Integer overflow in memory allocation"); } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -417,6 +417,9 @@ ZEND_VM_HANDLER(8, ZEND_CONCAT, CONST|TMPVAR|CV, CONST|TMPVAR|CV, SPEC(NO_CONST_ zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -3183,6 +3186,9 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) { size_t len = ZSTR_LEN(op1_str); + if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); ZVAL_NEW_STR(EX_VAR(opline->result.var), str); @@ -3190,6 +3196,9 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 5ee1c2c94daf..dc78ba4a08d0 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -6549,6 +6549,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_ !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) { size_t len = ZSTR_LEN(op1_str); + if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); ZVAL_NEW_STR(EX_VAR(opline->result.var), str); @@ -6556,6 +6559,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_ zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -8456,7 +8462,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_TMPVAR_HANDL size_t len = ZSTR_LEN(op1_str); if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { - zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation"); + zend_mm_safe_error_ex("Integer overflow in memory allocation"); } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -8465,6 +8471,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_TMPVAR_HANDL zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -8872,6 +8881,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_ !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) { size_t len = ZSTR_LEN(op1_str); + if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); ZVAL_NEW_STR(EX_VAR(opline->result.var), str); @@ -8879,6 +8891,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_ zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -10821,7 +10836,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_CV_HANDLER(Z size_t len = ZSTR_LEN(op1_str); if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { - zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation"); + zend_mm_safe_error_ex("Integer overflow in memory allocation"); } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -10830,6 +10845,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_CV_HANDLER(Z zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -11237,6 +11255,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) { size_t len = ZSTR_LEN(op1_str); + if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); ZVAL_NEW_STR(EX_VAR(opline->result.var), str); @@ -11244,6 +11265,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -14866,7 +14890,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CONST_HANDL size_t len = ZSTR_LEN(op1_str); if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { - zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation"); + zend_mm_safe_error_ex("Integer overflow in memory allocation"); } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -14875,6 +14899,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CONST_HANDL zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -15596,6 +15623,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_ !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) { size_t len = ZSTR_LEN(op1_str); + if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); ZVAL_NEW_STR(EX_VAR(opline->result.var), str); @@ -15603,6 +15633,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_ zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -16295,7 +16328,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_TMPVAR_HAND size_t len = ZSTR_LEN(op1_str); if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { - zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation"); + zend_mm_safe_error_ex("Integer overflow in memory allocation"); } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -16304,6 +16337,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_TMPVAR_HAND zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -17025,6 +17061,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) { size_t len = ZSTR_LEN(op1_str); + if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); ZVAL_NEW_STR(EX_VAR(opline->result.var), str); @@ -17032,6 +17071,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -17981,7 +18023,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CV_HANDLER( size_t len = ZSTR_LEN(op1_str); if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { - zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation"); + zend_mm_safe_error_ex("Integer overflow in memory allocation"); } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -17990,6 +18032,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CV_HANDLER( zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -18349,6 +18394,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) { size_t len = ZSTR_LEN(op1_str); + if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); ZVAL_NEW_STR(EX_VAR(opline->result.var), str); @@ -18356,6 +18404,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -39651,7 +39702,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CONST_HANDLER(Z size_t len = ZSTR_LEN(op1_str); if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { - zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation"); + zend_mm_safe_error_ex("Integer overflow in memory allocation"); } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -39660,6 +39711,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CONST_HANDLER(Z zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -42142,6 +42196,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) { size_t len = ZSTR_LEN(op1_str); + if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); ZVAL_NEW_STR(EX_VAR(opline->result.var), str); @@ -42149,6 +42206,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -43460,7 +43520,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_TMPVAR_HANDLER( size_t len = ZSTR_LEN(op1_str); if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { - zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation"); + zend_mm_safe_error_ex("Integer overflow in memory allocation"); } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -43469,6 +43529,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_TMPVAR_HANDLER( zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -45880,6 +45943,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) { size_t len = ZSTR_LEN(op1_str); + if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); ZVAL_NEW_STR(EX_VAR(opline->result.var), str); @@ -45887,6 +45953,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -48757,7 +48826,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CV_HANDLER(ZEND size_t len = ZSTR_LEN(op1_str); if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { - zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation"); + zend_mm_safe_error_ex("Integer overflow in memory allocation"); } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -48766,6 +48835,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CV_HANDLER(ZEND zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -51276,6 +51348,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) { size_t len = ZSTR_LEN(op1_str); + if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); ZVAL_NEW_STR(EX_VAR(opline->result.var), str); @@ -51283,6 +51358,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER zend_string_release_ex(op2_str, 0); } } else { + if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) { + zend_mm_safe_error_ex("Integer overflow in memory allocation"); + } str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 530620f6259f..e030b4413193 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2410,6 +2410,7 @@ static zend_class_entry* zend_accel_inheritance_cache_add(zend_class_entry *ce, } zend_map_ptr_extend(ZCSG(map_ptr_last)); + zend_accel_pending_ce_cache_begin(); #if ZEND_MM_ALIGNMENT < 8 /* Align to 8-byte boundary */ @@ -2456,6 +2457,7 @@ static zend_class_entry* zend_accel_inheritance_cache_add(zend_class_entry *ce, EG(errors) = NULL; ZCSG(map_ptr_last) = CG(map_ptr_last); + zend_accel_pending_ce_cache_commit(); zend_shared_alloc_destroy_xlat_table(); @@ -2780,6 +2782,9 @@ zend_result accel_post_deactivate(void) ZCG(cwd) = NULL; } + /* A persist window left through a bailout never published its slots */ + zend_accel_pending_ce_cache_discard(); + if (!ZCG(enabled) || !accel_startup_ok) { return SUCCESS; } diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index de5ec45de72c..72d3a239342b 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -225,6 +225,12 @@ typedef struct _zend_accel_globals { /* preallocated buffer for keys */ zend_string key; char _key[MAXPATHLEN * 8]; + + /* CE cache slots allocated during the current persist window, keyed by the + * address of the shared class name string. They are written into the + * strings by zend_accel_pending_ce_cache_commit() once ZCSG(map_ptr_last) + * covers them. NULL outside a persist window. */ + HashTable *pending_ce_cache; } zend_accel_globals; typedef struct _zend_string_table { @@ -322,7 +328,10 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type); zend_string* ZEND_FASTCALL accel_new_interned_string(zend_string *str); -uint32_t zend_accel_get_class_name_map_ptr(zend_string *type_name); +void zend_accel_get_class_name_map_ptr(zend_string *type_name); +void zend_accel_pending_ce_cache_begin(void); +void zend_accel_pending_ce_cache_commit(void); +void zend_accel_pending_ce_cache_discard(void); /* memory write protection */ #define SHM_PROTECT() \ diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index 7b4b4cbb1211..f1b1da2baa78 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -1696,6 +1696,7 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl int cache_it = 1; unsigned int actual_checksum; int ok; + size_t orig_map_ptr_last = 0; if (!full_path) { return NULL; @@ -1831,6 +1832,8 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl } memcpy(buf, mem, info.mem_size); zend_map_ptr_extend(ZCSG(map_ptr_last)); + orig_map_ptr_last = CG(map_ptr_last); + zend_accel_pending_ce_cache_begin(); } else { use_process_mem: buf = mem; @@ -1849,6 +1852,10 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl } zend_end_try(); if (!ok) { if (cache_it) { + /* The slots allocated by the failed unserialization are referenced + * only by the abandoned buffer, so they can be reclaimed. */ + zend_accel_pending_ce_cache_discard(); + CG(map_ptr_last) = orig_map_ptr_last; zend_shared_alloc_unlock(); goto use_process_mem; } else { @@ -1862,6 +1869,7 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl if (cache_it) { ZCSG(map_ptr_last) = CG(map_ptr_last); + zend_accel_pending_ce_cache_commit(); script->dynamic_members.checksum = zend_accel_script_checksum(script); script->dynamic_members.last_used = ZCG(request_time); diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index 49dfea34e33e..4ff93a12b33e 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -299,31 +299,78 @@ static HashTable *zend_persist_attributes(HashTable *attributes) return ptr; } -uint32_t zend_accel_get_class_name_map_ptr(zend_string *type_name) +/* We delay the publishing of CE cache slots until after ZCSG(map_ptr_last) is + * published. + * CE cache slots stored in interned strings are immediately visible to other + * processes, so if we fail to update ZCSG(map_ptr_last) after publishing a + * slot (due to a bailout/exit), that slot may be re-allocated for something + * else by other processes. */ +void zend_accel_pending_ce_cache_begin(void) +{ + ZEND_ASSERT(ZCG(locked)); + + /* A persist window left through a bailout caught by the caller (e.g. + * opcache_compile_file()) never published its slots. Drop them. */ + zend_accel_pending_ce_cache_discard(); + + ZCG(pending_ce_cache) = emalloc(sizeof(HashTable)); + zend_hash_init(ZCG(pending_ce_cache), 8, NULL, NULL, 0); +} + +void zend_accel_pending_ce_cache_commit(void) +{ + ZEND_ASSERT(ZCG(pending_ce_cache)); + /* Every pending slot must be covered by ZCSG(map_ptr_last) */ + ZEND_ASSERT(ZCSG(map_ptr_last) == CG(map_ptr_last)); + + ZEND_HASH_FOREACH_NUM_KEY_VAL(ZCG(pending_ce_cache), zend_ulong h, zval *zv) { + zend_string *type_name = (zend_string*)(uintptr_t)h; + + ZEND_ASSERT(!ZSTR_HAS_CE_CACHE(type_name)); + GC_SET_REFCOUNT(type_name, (uint32_t)Z_LVAL_P(zv)); + GC_ADD_FLAGS(type_name, IS_STR_CLASS_NAME_MAP_PTR); + } ZEND_HASH_FOREACH_END(); + + zend_accel_pending_ce_cache_discard(); +} + +void zend_accel_pending_ce_cache_discard(void) +{ + if (ZCG(pending_ce_cache)) { + zend_hash_destroy(ZCG(pending_ce_cache)); + efree(ZCG(pending_ce_cache)); + ZCG(pending_ce_cache) = NULL; + } +} + +void zend_accel_get_class_name_map_ptr(zend_string *type_name) { uint32_t ret; + zval *slot; if (zend_string_equals_literal_ci(type_name, "self") || zend_string_equals_literal_ci(type_name, "parent")) { - return 0; + return; } /* We use type.name.gc.refcount to keep map_ptr of corresponding type */ if (ZSTR_HAS_CE_CACHE(type_name)) { - return GC_REFCOUNT(type_name); + return; } if ((GC_FLAGS(type_name) & GC_IMMUTABLE) && (GC_FLAGS(type_name) & IS_STR_PERMANENT)) { + ZEND_ASSERT(ZCG(pending_ce_cache) && "Must be called inside a persist window"); + slot = zend_hash_index_lookup(ZCG(pending_ce_cache), (zend_ulong)(uintptr_t)type_name); + if (Z_TYPE_P(slot) != IS_NULL) { + /* Already allocated earlier in this window */ + return; + } do { ret = ZEND_MAP_PTR_NEW_OFFSET(); } while (ret <= 2); - GC_SET_REFCOUNT(type_name, ret); - GC_ADD_FLAGS(type_name, IS_STR_CLASS_NAME_MAP_PTR); - return ret; + ZVAL_LONG(slot, ret); } - - return 0; } static HashTable *zend_persist_backed_enum_table(HashTable *backed_enum_table) @@ -1312,6 +1359,9 @@ zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script #endif zend_map_ptr_extend(ZCSG(map_ptr_last)); + if (for_shm) { + zend_accel_pending_ce_cache_begin(); + } zend_accel_persist_class_table(&script->script.class_table); zend_hash_persist(&script->script.function_table); @@ -1336,6 +1386,7 @@ zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script if (for_shm) { ZCSG(map_ptr_last) = CG(map_ptr_last); + zend_accel_pending_ce_cache_commit(); } #ifdef HAVE_JIT diff --git a/ext/session/session.c b/ext/session/session.c index 114df24b4649..d72ae27b4481 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -3000,7 +3000,7 @@ static int php_session_rfc1867_callback(unsigned int event, void *event_data, vo if (php_session_rfc1867_orig_callback) { retval = php_session_rfc1867_orig_callback(event, event_data, extra); } - if (!PS(rfc1867_enabled)) { + if (!PS(rfc1867_enabled) || true) { return retval; } diff --git a/ext/zend_test/tests/observer_bug81430_2.phpt b/ext/zend_test/tests/observer_bug81430_2.phpt index 90e0fa5ce015..2cdbca9a7029 100644 --- a/ext/zend_test/tests/observer_bug81430_2.phpt +++ b/ext/zend_test/tests/observer_bug81430_2.phpt @@ -30,5 +30,3 @@ call_user_func([$r->getAttributes(A::class)[0], 'newInstance']); Fatal error: Allowed memory size of %d bytes exhausted %s in %s on line %d - - diff --git a/ext/zend_test/tests/observer_bug81435.phpt b/ext/zend_test/tests/observer_bug81435.phpt index 7b927e55fb19..e435292da0bd 100644 --- a/ext/zend_test/tests/observer_bug81435.phpt +++ b/ext/zend_test/tests/observer_bug81435.phpt @@ -45,4 +45,3 @@ a(); Fatal error: Allowed memory size of 20971520 bytes exhausted %s in %s on line %d - diff --git a/ext/zend_test/tests/observer_error_01.phpt b/ext/zend_test/tests/observer_error_01.phpt index 10b1e569b0fa..70a761016a8e 100644 --- a/ext/zend_test/tests/observer_error_01.phpt +++ b/ext/zend_test/tests/observer_error_01.phpt @@ -26,5 +26,3 @@ echo 'You should not see this.'; Fatal error: Allowed memory size of 2097152 bytes exhausted%s(tried to allocate %d bytes) in %s on line %d - - diff --git a/main/SAPI.c b/main/SAPI.c index 561cf6d598c6..656418a08e54 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -507,18 +507,23 @@ SAPI_API void sapi_deactivate_module(void) } if (SG(request_info).auth_user) { efree(SG(request_info).auth_user); + SG(request_info).auth_user = NULL; } if (SG(request_info).auth_password) { efree(SG(request_info).auth_password); + SG(request_info).auth_password = NULL; } if (SG(request_info).auth_digest) { efree(SG(request_info).auth_digest); + SG(request_info).auth_digest = NULL; } if (SG(request_info).content_type_dup) { efree(SG(request_info).content_type_dup); + SG(request_info).content_type_dup = NULL; } if (SG(request_info).current_user) { efree(SG(request_info).current_user); + SG(request_info).current_user = NULL; } if (sapi_module.deactivate) { sapi_module.deactivate(); diff --git a/main/main.c b/main/main.c index 9c62aa914eb0..b9994ccf9d24 100644 --- a/main/main.c +++ b/main/main.c @@ -1850,6 +1850,8 @@ void php_request_shutdown(void *dummy) for (i=0; i