Skip to content

Fix RC1 assumption for typed properties with __get #10833

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
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
16 changes: 6 additions & 10 deletions Zend/Optimizer/zend_inference.c
Original file line number Diff line number Diff line change
Expand Up @@ -3444,16 +3444,12 @@ static zend_always_inline int _zend_update_type_info(
} else if (ssa_op->op1_use >= 0 && !ssa->var_info[ssa_op->op1_use].is_instanceof) {
ce = ssa->var_info[ssa_op->op1_use].ce;
}
if (prop_info) {
Copy link
Member

Choose a reason for hiding this comment

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

If the problem is related to typed properties only, can we add a check for prop_info->type here?

Copy link
Member

Choose a reason for hiding this comment

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

I checked, the problem is related not to typed property but any unset property. So the patch looks right.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, sorry the comment is misleading. I'll adjust it.

/* FETCH_OBJ_R/IS for plain property increments reference counter,
so it can't be 1 */
if (ce && !ce->create_object && !result_may_be_separated(ssa, ssa_op)) {
tmp &= ~MAY_BE_RC1;
}
} else {
if (ce && !ce->create_object && !ce->__get && !result_may_be_separated(ssa, ssa_op)) {
tmp &= ~MAY_BE_RC1;
}
/* Unset typed properties will resort back to __get/__set */
if (ce
&& !ce->create_object
&& !ce->__get
&& !result_may_be_separated(ssa, ssa_op)) {
tmp &= ~MAY_BE_RC1;
}
if (opline->opcode == ZEND_FETCH_OBJ_IS) {
/* IS check may return null for uninitialized typed property. */
Expand Down