-
Notifications
You must be signed in to change notification settings - Fork 8k
Fixed possible crashes, because of inconsistent PCRE cache and opcache SHM reset #4161
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
|
@nikic please take a look. |
|
The originally proposed patch was a bit simpler https://gist.github.com/tony2001/b03b49ab53e0c0c7924cee8bb6b92c61 |
|
|
||
| /* Trivia */ | ||
| add_assoc_bool(return_value, "opcache_enabled", ZCG(enabled) && (ZCG(counted) || ZCSG(accelerator_enabled))); | ||
| add_assoc_bool(return_value, "opcache_enabled", ZCG(enabled) && ZCG(accelerator_enabled)); |
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.
Can the ZCG(enabled) && part be dropped?
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.
yes. right.
| realpath_cache_clean(); | ||
|
|
||
| accel_reset_pcre_cache(); | ||
| ZCG(pcre_reseted) = 0; |
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 don't really understand what's going on here. The cache is reset in the line above, but pcre_reseted is set to 0. Why is it necessary to reset the cache again?
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.
Ah, I think I got it. We already finished this restart, so this resets pcre_reseted=0 for the next one.
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.
Right. We reseted PCRE cache and set ZCG(pcre_reseted) = 1, to avoid multiple resets during restart pending, then reseted once again to repopulated cache with interned keys, and set ZCG(pcre_reseted) = 0 to be prepared for next restart.
nikic
left a comment
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 think this is fine.
|
Hello, this has been committed to the repo? Should be closed? |
|
For reference: 5c4d125 |
|
I'm looking into an issue we're having that might be related to this commit. Deactivating opcache or going back to 7.2.18 or 7.3.5 "solve" the problem. Could this be a side effect of this commit? |
|
@mweimerskirch Yes, this is https://bugs.php.net/bug.php?id=78106. We're trying to figure out what the problem is right now. |
Opcache reset may remove interned strings, that are used as keys in per-process PCRE caches.
PHP workers clear per-process PCRE cache on startup of next request after opcache reset, but crashes are possible in requests started before the actual reset.
To fix the problem, we reset PCRE caches on request startup, if we see restart pending event.
We also decide, if process may use opcache SHM once, by copying ZCSG(accelerator_enabled) into ZSG(accelerator_enabled) on request startup.