-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Heap Buffer Overflow in zval_undefined_cv. #11028
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
Comments
Actually this seems to be a whole category of "yield"-related issues with finally's. This also doesn't work: <?php
function test() {
try {
yield null => 0;
} finally {
return [];
}
}
echo "hi\n";
var_dump([...test()]);
echo "hi2\n"; and if you replace EDIT: progress.... Line 6236 in 7de83e2
|
I attempted a fix here: nielsdos@6650263 However, I found a variant of my previously reported issue which still crashes (may be different root cause?). It can be found here: nielsdos@6650263#diff-e61ec0f8972fbb546701b53555d59a0bfe720abdf3040f6b87c23a8a7f94db40 |
Maybe @bwoebi or @arnaud-lb can help, they've touched this code most recently 🙂 |
This script seems to result in a memory corruption since at least 7.4 according to https://3v4l.org/8SDGE The problem seems to be that we discard an exception that was thrown by an other frame, but the frame will still try to handle it. Since EG(exception) is NULL, it will not take the right code path, and continue to execute after having freed live variables.
@nielsdos your fix looks good. The case that still crashes is because EG(opline_before_exception) points to the generator op array, so in ZEND_HANDLE_EXCEPTION we call cleanup_unfinished_calls with an invalid op_num. We should probably save/restore EG(opline_before_exception) as well. |
Thanks. That makes sense. I missed the opline_before_exception part so that's why I didn't understand what was going on with my extra testcase. |
For analysis see php#11028 (comment)
For analysis see php#11028 (comment)
* PHP-8.1: Fix GH-11028: Heap Buffer Overflow in zval_undefined_cv.
* PHP-8.2: Fix GH-11028: Heap Buffer Overflow in zval_undefined_cv.
Description
The following code:
with
USE_TRACKED_ALLOC=1 USE_ZEND_ALLOC=0
Resulted in this output:
PHP Version
PHP 8.3.0-dev
Operating System
No response
The text was updated successfully, but these errors were encountered: