Repository navigation
Fix GH-24631: Report delayed OOM when compilation of the main script fails #24632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lazerg
wants to merge
7
commits into
php:PHP-8.4
Choose a base branch
from
lazerg:fix/gh-24631-delayed-oom-compile-fail
base: PHP-8.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
43723d2
Fix GH-24631: Report delayed OOM when compilation of the main script …
lazerg e305af1
Report delayed OOM on compile failure in fuzzer SAPI
lazerg 631a3b8
Report delayed OOM on compile failure in zend_eval_stringl() and php_…
lazerg 578a3ac
Make php -r delayed OOM test reliable on 32-bit
lazerg 8ce5d2e
Fix delayed OOM compile tests on Windows
lazerg 4f479a8
Drop NEWS entry
lazerg a2d33cc
Disable fatal_error_backtraces in OOM tests
lazerg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --TEST-- | ||
| OOM: Delayed OOM raised during compilation of the main script is reported when compilation fails | ||
| --SKIPIF-- | ||
| <?php | ||
| if (!getenv('TEST_PHP_EXECUTABLE')) die('skip TEST_PHP_EXECUTABLE is not set'); | ||
| ?> | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| $fname = __DIR__ . '/oom_compile_failure.test.php'; | ||
| file_put_contents($fname, "<?php\n\$a = '" . str_repeat('A', 3 << 20) . "';\n)\n"); | ||
|
|
||
| $php = getenv('TEST_PHP_EXECUTABLE'); | ||
| echo shell_exec(escapeshellarg($php) . ' -n -d fatal_error_backtraces=0 -d memory_limit=6M ' . escapeshellarg($fname) . ' 2>&1'); | ||
|
|
||
| ?> | ||
| --CLEAN-- | ||
| <?php | ||
| unlink(__DIR__ . '/oom_compile_failure.test.php'); | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Allowed memory size of 6291456 bytes exhausted %S(tried to allocate %d bytes) in %soom_compile_failure.test.php on line 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --TEST-- | ||
| OOM: Delayed OOM raised during compilation of php -r code is reported when compilation fails | ||
| --SKIPIF-- | ||
| <?php | ||
| if (!getenv('TEST_PHP_EXECUTABLE')) die('skip TEST_PHP_EXECUTABLE is not set'); | ||
| if (PHP_OS_FAMILY === 'Windows') die('skip the -r code is longer than Windows allows on the command line'); | ||
| ?> | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| $code = '$a = [' . str_repeat('1,', 50000) . ']; )'; | ||
|
|
||
| $php = getenv('TEST_PHP_EXECUTABLE'); | ||
| echo shell_exec(escapeshellarg($php) . ' -n -d fatal_error_backtraces=0 -d memory_limit=3M -r ' . escapeshellarg($code) . ' 2>&1'); | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Allowed memory size of 3145728 bytes exhausted %S(tried to allocate %d bytes) in Command line code on line 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| --TEST-- | ||
| OOM: Delayed OOM raised during compilation is reported by php -l | ||
| --SKIPIF-- | ||
| <?php | ||
| if (!getenv('TEST_PHP_EXECUTABLE')) die('skip TEST_PHP_EXECUTABLE is not set'); | ||
| ?> | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| $fname = __DIR__ . '/oom_compile_failure_lint.test.php'; | ||
| $php = getenv('TEST_PHP_EXECUTABLE'); | ||
|
|
||
| foreach (["\n", "\n)\n"] as $tail) { | ||
| file_put_contents($fname, "<?php\n\$a = '" . str_repeat('A', 3 << 20) . "';" . $tail); | ||
| // Windows rounds huge blocks up to 2MB, so leave room below the hard limit | ||
| echo shell_exec(escapeshellarg($php) . ' -n -d fatal_error_backtraces=0 -d memory_limit=6M -d memory_hard_limit_percent=400 -l ' . escapeshellarg($fname) . ' 2>&1'); | ||
| } | ||
|
|
||
| ?> | ||
| --CLEAN-- | ||
| <?php | ||
| @unlink(__DIR__ . '/oom_compile_failure_lint.test.php'); | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Allowed memory size of 6291456 bytes exhausted %S(tried to allocate %d bytes) in %soom_compile_failure_lint.test.php on line 2 | ||
| Errors parsing %soom_compile_failure_lint.test.php | ||
|
|
||
| Fatal error: Allowed memory size of 6291456 bytes exhausted %S(tried to allocate %d bytes) in %soom_compile_failure_lint.test.php on line 2 | ||
| Errors parsing %soom_compile_failure_lint.test.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this line
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is needed: zend_handle_delayed_oom() bails out here, so without it php -l on a valid file prints "No syntax errors detected" after the fatal error and oom_compile_failure_lint.phpt fails. I dropped the NEWS change.