-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Extend map_ptr before copying class table #9188
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
Conversation
if (EXPECTED(from_shared_memory)) { | ||
if (ZCSG(map_ptr_last) > CG(map_ptr_last)) { | ||
zend_map_ptr_extend(ZCSG(map_ptr_last)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just moving the if (EXPECTED(from_shared_memory)) {
block to the beginning of the function, and the if (ZCSG(map_ptr_last) > CG(map_ptr_last)) {
block at the beginning of the block.
@@ -743,6 +743,7 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { | |||
|
|||
#define ZSTR_SET_CE_CACHE_EX(s, ce, validate) do { \ | |||
if (!(validate) || ZSTR_VALID_CE_CACHE(s)) { \ | |||
ZEND_ASSERT((validate) || ZSTR_VALID_CE_CACHE(s)); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't understand what do you do with this assertion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's asserting that the ce cache is valid, even if validation is skipped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine
* PHP-8.1: [ci skip] NEWS Extended map_ptr before copying class table (#9188)
This reverts commit a697083.
A script loaded from shared memory may reference
map_ptr
entries higher thanCG(map_ptr_last)
, so we may need to extend themap_ptr
before loading the script.zend_accel_load_script()
does azend_map_ptr_extend(ZCSG(map_ptr_last))
, but I believe that it does it too late. In this change I move thezend_map_ptr_extend(ZCSG(map_ptr_last))
before anything else inzend_accel_load_script()
. I moved the wholeif (EXPECTED(from_shared_memory)) {
block up to avoid duplicating the condition.Fixes #9164
I understand that
map_ptr
is what allows opcache structures to be immutable, and to be used directly from SHM without copy. Each php process has a local mutablemap_ptr
vector, in which opcache structures can reference elements by index. The opcache can allocate newmap_ptr
indices in one process, but other processes need to extend the vector themselves.