-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Always use Zend signal handling #5710
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
This global variable controls whether the Zend deferred signal handlers are installed at the beginning of each request or not. Interestingly, it is set to 1 on initialization, and there is only *one* place where the value is modified. This is in OPCache, where the global is temporarily set to 0 while preloading. Why is this? Discussion on GitHub revealed that the purpose was so that what happens during preloading would not affect subsequent requests... but the fact is, as long as Zend signal handling is enabled, the Zend signal handlers will always be installed on each subsequent request, so installing them during preloading will not affect anything.
Since Zend Signal Handling was never available on Windows, these checks should most likely be changed to Edit: Note that Windows does have some signal functionality available, but it is not used, so you may have to explicitly disable it for Wiindows. |
b93f902
to
fb1f674
Compare
@KalleZ Thank you for the review! Correct me if I'm wrong, but I don't think the existing code does anything to explicitly disable Zend SH on Windows -- it's just disabled by virtue of the fact that Windows doesn't have Is that not so? Looking forward to further feedback. |
There's a build failure on AppVeyor:
|
Just fixing it up. Sorry! |
The issue is that Windows does not define |
fb1f674
to
be55ff1
Compare
Thanks for commenting again. But it's actually the opposite; the AppVeyor build logs show that the code in the bottom part of zend_signal.h, which is used when There is another problem with the build, which I am trying to fix. |
Being able to choose whether Zend signal handling should be used or not does not benefit users (or packagers) of PHP in any way. The use of Zend SH is a purely internal implementation detail, so there is no need for the build config parameters --{disable,enable}-zend-signals. By just choosing one way to do things (in this case, always using Zend signal handling), we can simplify the codebase a bit. Of course, some platforms do not have the concept of signals and signal handlers at all. That is why previously, Zend signal handling was automatically disabled if the platform did not have `sigaction`. In harmony with that, we now guard the implementation of Zend signal handling with `#ifdef HAVE_SIGACTION`.
be55ff1
to
1fc5f3d
Compare
It's fixed now. Sorry about that. 😓 |
Well whether or not it compiles on Windows is one thing, it needs to be stable if we are going to enable it. There was some mentions of this in the RFC that implemented the Zend signal handling, more specifically it mentions that ZTS support was at the time yet to be implemented for Windows. The "Improved stability" section near the top also made an observation for some SAPIs with signals on Windows. |
I'm sorry if what I said was not clear. My point was that with this patch, Zend signal handling is already disabled in Windows. It is "automatically" disabled for exactly the same reason as was the case before this patch -- Windows does not have If you look at the existing code already on With this patch, it works in just the same way. There is no change in that regard. Hope this is making sense now. |
@KalleZ Sorry that I seem to be struggling to get my point across. Please have a look at the existing code for configuring Zend SH: Lines 306 to 320 in 63cb47a
You will see that there is no mention of WIN32 there. However, look at lines 312-314... that is what currently causes Zend SH to be disabled on Windows. This patch uses the very same criteria to ensure that Zend SH is disabled on Windows. See https://github.com/php/php-src/pull/5710/files#diff-ea48211bef574717fa8ad58ed9c829eeR39. |
Could you maybe have a look here? https://bugs.php.net/bug.php?id=79464 Signaling on ZTS seems to be broken fundamentally (due to threads being used when signals are per process defined) Maybe it would be the right time to fix this as well? For my embed ZTS builds zend signals are always disabled. Having them enabled had some unwanted side effects as far as i remember. |
I have a fix already prepared for the issue of execution timeouts not working on ZTS, but am waiting for the issue of Zend signal handling to be worked out first... Here I had proposed to remove Zend signal handling: #5591. That was not accepted, so I opened this PR to always turn it on instead. My view is that there is no reason to have a compile-time config parameter for Zend SH: if it is needed, it should always be on. If it is not needed, it should be removed. |
I added my comment in the other PR. I would prefer to have Zend Signals removed because in my use case i they do not play well with threading. When this PR get's merged it would need to patch them out again ;) Do you have a branch where i could try the other fix? |
Hi from much less popular mainframe OS BS2000 (namely its POSIX subsystem). I second paresy. On recent php 7.4.8 zend signals break a lot of tests on BS2000 (when disabled ~600 tests pass additionally). Moreover with zend signals some phpdbg tests loop infinitely. I truss'ed one of them and the loop was:
I think it is very difficult if not impossible to implement universal zend signals which behave correctly on all kinds of signal system implementation. So please leave it at least configurable (--disable-zend-signals). |
@alexdowad: You mentioned you had a fix "ready" for the mentioned bug report? Would you be able to share it somewhere? Also i'd be interested which would be the proper way to proceed with your two PR's? I'd be in favor of closing this one and merging the one to remove Zend SH. As far as i have seen in the other PR the only question was about a performance analysis requested by dstogov. |
Dear @paresy, thanks for your interest in my work. You can have a look at https://github.com/alexdowad/php-src/tree/refactor-timeout if you like. That code is a WIP, but was getting close to being ready to merge. Some commits would be squashed first, etc. It works in CI, and I have confirmed that on Mac OS, the libdispatch code is actually being used.
Ask the maintainers. |
The PR looks outdated. |
Follow up to PR #5591.
Instead of eliminating Zend signal handling altogether, simplify things in a different way; always enable Zend SH, thus eliminating the
--{disable,enable}-zend-signals
configuration parameters.