fix: fatal php shutdowns#2293
Conversation
|
FPM wraps the whole while loop accepting requests, we don't, we only wrap the actual script execution. Not sure what else can lead to a bailout. I just know that bailing out without a try-catch will crash the process, like in the muli curl reproducer from #2268. We could also wrap the entire while loop, might be better for performance. |
|
Yeah we should wrap the loop then, too and exit out gracefully to restart the thread. Less impact on the good case (no crash). |
|
The only unfortunate thing is that I don't know how to test this, maybe with a custom extension that intentionally fails on shutdown? |
Not a good idea, we'd need to compile it in statically for tests and make it only load on some signal we give it. Perhaps the max_execution_time could be provoked? |
|
|
|
Hey, could you please rebase? Is it ready to be merged? |
|
Ready to be merged from my side after rebase. |
|
Did some additional testing with symfony/laravel, ready to merge from my side as well 👍 |

Fixes #2268 (and maybe others)
In that issue, a timeout during a
curl_multirequest leads to a fatal error and bailout duringphp_request_shutdown(). After looking at the FPM implementation I realized it also wrapsphp_request_shutdown()with azend_bailout, which we don't. This PR wraps the shutdown function and restarts ZTS in case of an unexpected bailout, which fixes #2268 and prevents any potential crashes from bailouts during shutdown.Still a draft since I think it might make sense to wrap the whole request loop in a
zend_try.