-
Notifications
You must be signed in to change notification settings - Fork 8k
Bring back preloading on Windows #19985
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
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.
Shouldn't you check for a "good" SAPI and/or disable "attaching" for "bad" ones?
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.
8ba10b8 disables reattachment in all SAPIs when ASLR is enabled
Without reattachment, we could likely also remove the ZEND_COMPILE_IGNORE_INTERNAL_CLASSES
workarounds in ext/opcache/ZendAccelerator.c.
Uh oh!
There was an error while loading. Please reload this page.
Support for preloading on Windows was removed in [1] [2]:
This is because on Windows the opcache SHM may be reattached from different processes, whose address layout is different, due to ASLR. Therefore SHM can't reference non-SHM addresses on Windows.
One solution is to drop support for reattachment, as suggested in [3]. Reattachment is only needed by process-based SAPIs: FastCGI. The Apache2 SAPI uses reattachment as well, but merging [4] would fix that. [5] would ensure that we have at least 2 Windows SAPIs that don't need reattachment. The FastCGI SAPI would consume more memory on Windows. CLI tools running multiple PHP processes, with opcache enabled, would also consume more memory.
I've also suggested this in [4][7], but this didn't get traction.
But, what seems to have passed under the radars is that since 7.4 we don't reattach at all when ASLR is enabled (or at least when the address layout changed) [6]. Therefore any of the ASLR-related limitations no longer have a reason to exist, as we never have reattachment and ASLR at the same time.
Therefore we could bring back preloading on Windows. This is what this PR does.
Alternatively we could bring back reattachment on ASLR by fixing the invariant "SHM can not reference non-SHM addresses". We can achieve this by adding indirections in places that reference non-SHM addresses, such as in
zend_op.handler
. As this invariant has not been tested for 6 years, we may discover that other places need to be fixed. We could bring back preloading on Windows if we added these indirections onzend_class_entry.parent
and other references to internal definitions. However this adds complexity and slows down the VM.Bringing back preloading on Windows would facilitate [8]. The "SHM can not reference non-SHM addresses" invariant blocks it.
Any thoughts?
(Windows test failure unrelated.)