Skip to content

fixes zend_type_release not freeing nested type lists #11884

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 4 commits into from

Conversation

ju1ius
Copy link
Contributor

@ju1ius ju1ius commented Aug 5, 2023

Closes #11883

@iluuu1994 iluuu1994 requested a review from Girgias August 12, 2023 14:48
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

As far as I can see persistent is always true for destroying arg infos of internal classes.

Also having a test added to the zend_test extension would be helpful.

@ju1ius
Copy link
Contributor Author

ju1ius commented Aug 12, 2023

Also having a test added to the zend_test extension would be helpful.

The issue I'm having right now is that the valgrind configuration used by run-tests.php does not report this leak, it is only reported when --leak-check=full is set... 😒

Any particular reson why this flag is not enabled?

@ju1ius ju1ius force-pushed the ju1ius/fix-zend_type_release branch from 4d121b5 to 48f1512 Compare August 12, 2023 23:31
@ju1ius ju1ius requested a review from iluuu1994 as a code owner August 12, 2023 23:31
ju1ius added 3 commits August 13, 2023 02:01
Note that this test only fails if valgrind is run with
the `--leak-check=full` flag.
@ju1ius ju1ius force-pushed the ju1ius/fix-zend_type_release branch 2 times, most recently from cf754a9 to 1367c2b Compare August 13, 2023 08:18
@ju1ius ju1ius force-pushed the ju1ius/fix-zend_type_release branch from 1367c2b to 29e861b Compare August 13, 2023 09:36
@Girgias
Copy link
Member

Girgias commented Aug 13, 2023

I've been digging into this, as I don't think the two different functions are needed. I can trigger the double use after free even without opcache using ASAN, and I think that is an issue due for some reason the type list is not allocated on an arena when it should.

In other news, I think I found a bug of using DNF types in a trait property and binding it to a class... so thank you for finding that out indirectly :')

@ju1ius
Copy link
Contributor Author

ju1ius commented Aug 14, 2023

I've been digging into this, as I don't think the two different functions are needed. I can trigger the double use after free even without opcache using ASAN, and I think that is an issue due for some reason the type list is not allocated on an arena when it should.

So, what you mean is that the changeset in 9a1c9f0 is correct, but the failing test is actually a bug in the engine, that you can reproduce even with the changes in 90ca716?

In this case, should I close this PR in favour of #11961 ?

@Girgias
Copy link
Member

Girgias commented Aug 14, 2023

I've been digging into this, as I don't think the two different functions are needed. I can trigger the double use after free even without opcache using ASAN, and I think that is an issue due for some reason the type list is not allocated on an arena when it should.

So, what you mean is that the changeset in 9a1c9f0 is correct, but the failing test is actually a bug in the engine, that you can reproduce even with the changes in 90ca716?

In this case, should I close this PR in favour of #11961 ?

So, I think there was some other issue as to how I was getting the leak, but now it is just with opcache. And yes basically there is a bug somewhere in the engine/opcache which changes how the inner intersection type list is allocated, and this causes only an issue for property types, that are the only ones that do not store their types in a persistent manner for userland types. However, it should be arena allocated if it is a userland type.

I am wondering if this is some issue caused by delayed early binding as this is like a "second" pass of the early binding reading: https://www.npopov.com/2021/10/20/Early-binding-in-PHP.html as this happens, seemingly, only when some of the class dependencies cannot be loaded.

@Girgias
Copy link
Member

Girgias commented Aug 15, 2023

The proper fix was 02a80c5

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

Successfully merging this pull request may close these issues.

memory leak in zend_type_release
2 participants