Skip to content

Fix OSS-Fuzz #61712 #12062

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

Closed
wants to merge 1 commit into from
Closed

Conversation

nielsdos
Copy link
Member

Because the error handler is invoked after the property is updated, the error handler has the opportunity to remove it before the property is returned.

Switching the order around fixes this issue. The comments mention that the current ordering prevents overwriting the EG(std_property_info) field in the error handler. EG(std_property_info) no longer exists as it was removed in 7471c21. Back then a global was used to store the returned property info, but as this is no longer the case there is no longer a need to protect against overwriting a global.

Because the error handler is invoked after the property is updated,
the error handler has the opportunity to remove it before the property
is returned.

Switching the order around fixes this issue. The comments mention that
the current ordering prevents overwriting the EG(std_property_info)
field in the error handler. EG(std_property_info) no longer exists as it
was removed in 7471c21. Back then a global was used to store the
returned property info, but as this is no longer the case there is no
longer a need to protect against overwriting a global.
@nielsdos nielsdos requested review from iluuu1994 and dstogov August 27, 2023 17:54
Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK to merge this into master, but I'm not completely sure about the old branches.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This slightly changes behavior for observing the property inside the error handler. But it's unlikely that somebody relies on this.

#[AllowDynamicProperties]
class C {
    function error($_, $msg) {
        echo $msg, "\n";
        var_dump($this->a);
    }
}

$c = new C;
set_error_handler([$c, 'error']);
$c->a %= 10;
var_dump($c->a);

Currently:

Undefined property: C::$a
NULL
int(0)

After:

Undefined property: C::$a

Warning: Undefined property: C::$a in /home/ilutov/Developer/php-src/test.php on line 6
NULL
int(0)

The warning is now emitted twice. This is certainly acceptable in master. It also probably makes more sense, as the user never set it to null.

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't object against merging this into old branches, but as @iluuu1994 showed this changes behavior, and I hardly ever expect if this bug may affect any app.

@nielsdos
Copy link
Member Author

I hardly ever expect if this bug may affect any app.

I agree. Let's go with master branch for safety reasons.

@nielsdos nielsdos closed this in a3a3964 Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants