Skip to content

Fix handling of references in nested data #4497

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

Conversation

nikic
Copy link
Member

@nikic nikic commented Aug 8, 2019

This addresses the issue from #4489 (comment).

@nikic
Copy link
Member Author

nikic commented Aug 8, 2019

The issue is that nested data removal stops at any node that is not part of the root buffer. Because references aren't added to it, we always stop at references and may miss nested data that way.

@@ -71,6 +71,7 @@ static void ZEND_FASTCALL zend_string_destroy(zend_string *str)
static void ZEND_FASTCALL zend_reference_destroy(zend_reference *ref)
{
ZEND_ASSERT(!ZEND_REF_HAS_TYPE_SOURCES(ref));
GC_REMOVE_FROM_BUFFER(ref);
i_zval_ptr_dtor(&ref->val);
efree_size(ref, sizeof(zend_reference));
Copy link
Member

Choose a reason for hiding this comment

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

There are some other places where the zend_reference may be deallocated (e.g. zend_assign_to_variable)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm wondering whether we actually need to handle other places: We are only adding resources to the root buffer during garbage collection here, not before. So references with a root buffer entry shouldn't be visible from normal code.

@nikic
Copy link
Member Author

nikic commented Aug 9, 2019

Fixed by 9b43e29 instead.

@nikic nikic closed this Aug 9, 2019
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.

2 participants