diff --git a/.github/actions/apt-x32/action.yml b/.github/actions/apt-x32/action.yml index 14182e768795..0f27b88497ac 100644 --- a/.github/actions/apt-x32/action.yml +++ b/.github/actions/apt-x32/action.yml @@ -9,10 +9,10 @@ runs: OPCACHE_TLS_TESTS_DEPS="gcc clang lld" export DEBIAN_FRONTEND=noninteractive - dpkg --add-architecture i386 - apt-get update -y | true + sudo dpkg --add-architecture i386 + sudo env DEBIAN_FRONTEND=noninteractive apt-get update -y | true # TODO: Reenable postgresql + postgresql-contrib packages once they work again. - apt-get install -y \ + sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y \ autoconf \ bison \ curl \ diff --git a/.github/actions/install-linux-x32/action.yml b/.github/actions/install-linux-x32/action.yml index 4ef87ee03fd3..95d7fc738b1c 100644 --- a/.github/actions/install-linux-x32/action.yml +++ b/.github/actions/install-linux-x32/action.yml @@ -5,11 +5,11 @@ runs: - shell: bash run: | set -x - make install - mkdir -p /etc/php.d - chmod 777 /etc/php.d - echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini - echo pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/pdo_mysql.ini - echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini - echo opcache.protect_memory=1 >> /etc/php.d/opcache.ini - echo opcache.preload_user=root >> /etc/php.d/opcache.ini + sudo make install + sudo mkdir -p /etc/php.d + sudo chmod 777 /etc/php.d + echo mysqli.default_socket=/var/run/mysqld/mysqld.sock | sudo tee /etc/php.d/mysqli.ini > /dev/null + echo pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock | sudo tee /etc/php.d/pdo_mysql.ini > /dev/null + echo opcache.enable_cli=1 | sudo tee /etc/php.d/opcache.ini > /dev/null + echo opcache.protect_memory=1 | sudo tee -a /etc/php.d/opcache.ini > /dev/null + echo opcache.preload_user=root | sudo tee -a /etc/php.d/opcache.ini > /dev/null diff --git a/.github/actions/test-linux/action.yml b/.github/actions/test-linux/action.yml index e89c942d52e1..f304133a2b20 100644 --- a/.github/actions/test-linux/action.yml +++ b/.github/actions/test-linux/action.yml @@ -9,9 +9,6 @@ inputs: jitType: default: 'disable' required: false - idleCpu: - default: 'false' - required: false runs: using: composite steps: @@ -50,7 +47,6 @@ runs: -d opcache.jit=${{ inputs.jitType }} \ -d opcache.protect_memory=1 \ -d opcache.jit_buffer_size=64M \ - ${{ inputs.idleCpu == 'true' && '-j$(($(/usr/bin/nproc) - 1))' || '-j$(/usr/bin/nproc)' }} \ -g FAIL,BORK,LEAK,XLEAK \ --no-progress \ --offline \ diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index dcd61adf17c8..e72dd8ba74d0 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -188,7 +188,6 @@ jobs: ${{ matrix.asan && '--asan' || '' }} ${{ matrix.repeat && '--repeat 2' || '' }} ${{ matrix.variation && '-d zend_test.observer.enabled=1 -d zend_test.observer.show_output=0' || '' }} - idleCpu: ${{ matrix.asan && 'true' || 'false' }} - name: Test Tracing JIT if: ${{ inputs.all_variations || matrix.asan }} uses: ./.github/actions/test-linux @@ -230,15 +229,14 @@ jobs: fail-fast: false matrix: ${{ fromJson(inputs.branch).jobs.LINUX_X32.matrix }} name: "LINUX_X32_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" - runs-on: ubuntu-latest + # The container seccomp profile blocks i386 socket syscalls used by the test suite. + runs-on: ubuntu-${{ fromJson(inputs.branch).config.ubuntu_version }} timeout-minutes: 180 - container: - image: ubuntu:${{ fromJson(inputs.branch).config.ubuntu_version }} env: - MYSQL_TEST_HOST: mysql - PDO_MYSQL_TEST_DSN: mysql:host=mysql;dbname=test - PDO_MYSQL_TEST_HOST: mysql - PDO_FIREBIRD_TEST_DSN: firebird:dbname=firebird:test.fdb + MYSQL_TEST_HOST: 127.0.0.1 + PDO_MYSQL_TEST_DSN: mysql:host=127.0.0.1;dbname=test + PDO_MYSQL_TEST_HOST: 127.0.0.1 + PDO_FIREBIRD_TEST_DSN: firebird:dbname=localhost:test.fdb services: mysql: image: mysql:8.4 diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 38f0c837a9fe..355b54bed88b 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3458,6 +3458,10 @@ ZEND_API void zend_activate_modules(void) /* {{{ */ const zend_module_entry *module = *p; if (module->request_startup_func(module->type, module->module_number)==FAILURE) { + /* Surface a delayed OOM before reporting a generic module startup failure. */ + if (ZEND_HAS_OOM()) { + zend_handle_delayed_oom(); + } zend_error(E_WARNING, "request_startup() for %s module failed", module->name); exit(1); } diff --git a/main/main.c b/main/main.c index ee7d1cca69b5..03b9f2dafd3a 100644 --- a/main/main.c +++ b/main/main.c @@ -1922,6 +1922,9 @@ zend_result php_request_startup(void) /* PG(during_request_startup) = 0; */ php_hash_environment(); + if (ZEND_HAS_OOM()) { + zend_handle_delayed_oom(); + } zend_activate_modules(); PG(modules_activated)=1; } zend_catch { diff --git a/tests/basic/gh24787_delayed_oom_request_startup.phpt b/tests/basic/gh24787_delayed_oom_request_startup.phpt new file mode 100644 index 000000000000..710730762a7c --- /dev/null +++ b/tests/basic/gh24787_delayed_oom_request_startup.phpt @@ -0,0 +1,59 @@ +--TEST-- +GH-24787 (Delayed OOM during request startup is handled as a fatal error) +--SKIPIF-- + +--FILE-- + 'POST', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH' => (string) strlen($body), + 'SCRIPT_FILENAME' => $script, + 'REDIRECT_STATUS' => '1', + ]; + $process = proc_open($command, [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes, null, $environment); + fwrite($pipes[0], $body); + fclose($pipes[0]); + $output = stream_get_contents($pipes[1]) . stream_get_contents($pipes[2]); + fclose($pipes[1]); + fclose($pipes[2]); + proc_close($process); + + $rinitFailed = $rinitFailed || str_contains($output, 'request_startup()'); + $oomReported = $oomReported || str_contains($output, 'Allowed memory size'); +} +unlink($script); + +echo !$rinitFailed && $oomReported ? "OOM handled\n" : "RINIT failure or no OOM reported\n"; +?> +--EXPECT-- +OOM handled