Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/actions/apt-x32/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
16 changes: 8 additions & 8 deletions .github/actions/install-linux-x32/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions .github/actions/test-linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ inputs:
jitType:
default: 'disable'
required: false
idleCpu:
default: 'false'
required: false
runs:
using: composite
steps:
Expand Down Expand Up @@ -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 \
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
59 changes: 59 additions & 0 deletions tests/basic/gh24787_delayed_oom_request_startup.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
--TEST--
GH-24787 (Delayed OOM during request startup is handled as a fatal error)
--SKIPIF--
<?php
if (!getenv('TEST_PHP_CGI_EXECUTABLE')) {
die('skip php-cgi not available');
}
if (!extension_loaded('uri')) {
die('skip uri extension not available');
}
?>
--FILE--
<?php
$script = tempnam(sys_get_temp_dir(), 'gh24787');
file_put_contents($script, "<?php echo \"request completed\\n\";");

// The field count needed to reach the startup gap varies by build and platform.
$counts = range(1700, 1950, 4);
$rinitFailed = false;
$oomReported = false;
foreach ($counts as $count) {
$post = [];
for ($i = 0; $i < $count; $i++) {
$post[] = 'p' . $i . '=' . str_repeat('y', 4000);
}
$body = implode('&', $post);

$command = [
getenv('TEST_PHP_CGI_EXECUTABLE'),
'-n',
'-d', 'memory_limit=8M',
'-d', 'post_max_size=64M',
'-d', 'max_input_vars=20000',
'-d', 'html_errors=0',
];
$environment = [
'REQUEST_METHOD' => '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
Loading