Skip to content

Make var_export/debug_zval_dump first check for infinite recursion on the object before properties #8045

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

Conversation

TysonAndre
Copy link
Contributor

@TysonAndre TysonAndre commented Feb 5, 2022

This test case previously failed with an assertion error in debug builds
(for updating an index of the array to set it to the same value it already had)

After the new check on recursion on the object, repeat the existing check on the return value of get_properties_for
in case there was a reason for doing it that way.

  1. HT_ASSERT_RC1(ht); would fail for SplFixedArray and related
    datastructures.

  2. In order for a native datastructure to correctly implement
    *get_properties_for for var_export's cycle detection,
    it would need to return the exact same array every time prior to this PR.

    This would prevent SplFixedArray or similar classes from returning a
    temporary array that

    1. Wouldn't be affected by unexpected mutations from error handlers
    2. Could be garbage collected instead.

Note that SplFixedArray continues to need to return object->properties
until php 9.0, when dynamic properties are forbidden.
(to display dynamic properties when debugging, until then)

Closes GH-8044

This test case previously failed with an assertion error in debug builds
(for updating an index of the array to set it to the same value it already had)

Then repeat the existing check on the return value of `get_properties_for`
in case there was a reason for doing it that way.

1. `HT_ASSERT_RC1(ht);` would fail for SplFixedArray and related
   datastructures.
2. In order for a native datastructure to correctly implement
   `*get_properties_for` for var_export's cycle detection,
   it would need to return the exact same array every time prior to this PR.

   This would prevent SplFixedArray or similar classes from returning a
   temporary array that

   1. Wouldn't be affected by unexpected mutations from error handlers
   2. Could be garbage collected instead.

Closes phpGH-8044
@TysonAndre TysonAndre changed the title Make var_export first check for infinite recursion on the object before properties Make var_export/debug_zval_dump first check for infinite recursion on the object before properties Feb 5, 2022
@TysonAndre TysonAndre closed this Feb 5, 2022
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.

var_export emits debug assertion errors for HT_ASSERT_RC1(ht); in builds for SplFixedArray circular references
1 participant