fix: safe opcache_reset#2073
Conversation
# Conflicts: # caddy/caddy_test.go
|
Hi @AlliBalliBaba, any news on this side? 🙂 |
|
I experimented a lot with juggling thread states, but not sure it's possible to make a reset fully safe from our side alone. There are 2 main race conditions:
The first race condition kind of gets mitigated by the changes in this PR. THe second one would need to somehow be fixed in php-src or requires a hook to reject opcache_resets. |
|
Can we try doing what we do with the environment functions and simply override/replace the existing one:
|
|
Yeah I tried that as well. But an But maybe overwriting the user function would still be a good first step 👍 |
I tried this and it kind of works, but workers are an issue. Only got it working by locking new requests, draining all workers, doing the reset, restarting all workers and then unlocking. |
|
Oh I just realized that overwriting |
|
Yes, I hard linked because opcache is always active in 8.5+ (which is where I test). I'll tidy up my changes and merge them on top of this branch when I get to it. |
|
Maybe we can make it a requirement also for other PHP versions, not sure how many installations there are without it. |
|
You already had logic to check whether opcache exists in the branch so I only had to pick in a minor change here. Let's see if tests pass. Edit: well, apparently not. I only tested with 8.5 locally and guess what's passing x) Okay, I think I get the issue now. Hard linking to opcache won't help because the init chain for shared extensions is different than for static extensions, which is why it works for me locally, but not in CI in < 8.5. Need to wait with actually calling opcache reset until the extension is properly loaded. |
e54cd96 to
5c8e340
Compare
5c8e340 to
1d75824
Compare
e7bd25a to
0d87765
Compare
|
Alright, we're down to php 8.2 segfaulting. I'm not terribly keep to find out why. |
|
Down to only debian 8.2 failing... |
|
@henderkes do you remember what exactly fixed 8.2 for you before? I think I re-introduced the failure for some 8.2 versions while fixing a different race. |
It turned out that the failures were unrelated to the branch changes. I merged main so if it's still happening now it'll be something different. |
Not sure why... I've ran the exact same docker container tests 100x locally and didn't run into the failure a single time. |
…rankenphp into fix/opcache-safe-reset
Replace the ad-hoc opcache test with the canonical concurrency test and fixtures from PR php#2073 (caddy TestOpcacheReset, opcache_reset.php, require.php): 500 mixed sleep.php / opcache_reset.php requests across 20 workers. Verified passing against this implementation with opcache enabled and every opcache_reset() routed through the thread-safe coordinator. https://claude.ai/code/session_01K4jwAnp9mA9ApgaFiJDf6d
|
Hey, quick question, would be really great if we could get this PR merged soonish, because it's blocking a lot of our team members. Is there any estimation for how long this takes to fix or can we assist in some way? |
|
so i even checked out this branch and built the docker image for it locally, but i still run into |
|
zend_mm_heap_corrupted is generally an error in upstream php-src or caused by a not-fully-zts-compatible extension. This PR here would fix segfaults, rather than zend memory manager logic errors |
Idea to fix #1737
Just a WIP, to test in CI.