-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #75932: zend_user_opcode_handlers crash #3087
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
Only call a user_opcode_handler if it has been set, otherwise call the original opcode handler. When using opcache, a user handler will not be set if the cache was created by an extension that used its own handlers, then hit later by a process not using the extension. Also fixes #75886.
Probably @dstogov is the best person to look at this. I think the actual solution here might be to include the fact that user opcodes are used in the system hash, to ensure that cached opcodes are not reused at all in this case. (Actually we might want to check all loaded extensions -- I remember we already have a bunch of optimizations disabled on windows because we can't rely on the same exts being loaded there.) |
User opcode handlers should be set once and forever (at MINIT). |
So this doesn't look like the best thing to do ... closing ... sorry about the delay ... |
@krakjoe No worries. I should have replied to the feedback I asked for, but I got a bit behind. Is it possible that this could be re-opened so it could be discussed a little more?
@dstogov Sure, but how do folk know that they must do that. I don't think it is correct behaviour to crash. It is quite common for people to disable an extension like xdebug (for performance reasons). IDEs offer this functionality and so do CI services. And if opcache file-caching is being used then there could be a crash if xdebug is run first and the opcode handlers are cached. See https://bugs.php.net/bug.php?id=75932 My use case is for composer/xdebug-handler, which is part of Composer and is used in a few other big projects. This restarts a process without xdebug loaded and will crash on Windows regardless of whether file-caching it being used. See https://bugs.php.net/bug.php?id=75886 xdebug-handler works round this issue by disabling opcache cli in the restarted process. It seems inherently wrong to me that PHP should happily use a nil pointer without checking .
@nikic My solution (if it is realistic) allows opcodes that exist to run, rather than not using any at all. |
If you change user opcode handlers at run-time, you introduce race-conditions in ZTS build and get crash soon or later. |
Thanks @dstogov , but how are the opcode handlers are being changed at runtime? All I have suggested doing is returning |
I agree, but currently the system hash is calculated during OPcache startup, and the user opcodes are not necessarily set then (depends on loading order). Not sure, if and how that could be solved. |
Only call a user_opcode_handler if it has been set, otherwise call the
original opcode handler. When using opcache, a user handler will not be
set if the cache was created by an extension that used its own handlers,
then hit later by a process not using the extension. Also fixes #75886.