Skip to content
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

Support neighbouring extension in the ZendMM custom handlers hook in zend_test #12792

Conversation

realFlowControl
Copy link
Contributor

@realFlowControl realFlowControl commented Nov 27, 2023

This PR will add support for neighouring extensions in the zend_mm_set_custom_handlers() hook, as USE_ZEND_ALLOC=0 technically installs a custom memory handler in the ZendMM and is used for the ASAN tests.

This realtes to #12768 and #12758

As the PHP 8.1 merge window has closed, this targets PHP 8.2

@realFlowControl
Copy link
Contributor Author

@bwoebi can I ping you to review this PR?

Comment on lines +527 to +530
int flag = 0;
memcpy(&flag, heap, sizeof(int));
int new_flag = 0;
memcpy(heap, &new_flag, sizeof(int));
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, no.
It works, but we should not do it this way, especially not advertise that in php-src itself.

You probably should include a

#ifndef ZEND_ALLOC_HIDE_STRUCTS
struct _zend_mm_heap {
#if ZEND_MM_CUSTOM
    int use_custom_mm_heap;
#endif
}
#endif

to zend_alloc.h, with #define ZEND_ALLOC_HIDE_STRUCTS 1 in zend_alloc.c

and have it public API.

If we rely on such implementation details, it can well just be public.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I get the point and the zend_test_prepare_zendmm_for_call() is super ugly 😉
OTOH I would rather not make the use_custom_mm_heap flag public just for the sake of this test.

I am about to prepare a PR that would add a gc and shutdown custom handler (#13432) that might help solve this.

@realFlowControl
Copy link
Contributor Author

Closing this in favour of #13432

@realFlowControl realFlowControl deleted the fix-asan-for-zendmm-zend-test branch June 17, 2024 18:38
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.

2 participants