From 69fc5b22ba58b481fcbf0f19ab516b904c3ac4ad Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 10 Dec 2019 14:29:58 +0100 Subject: [PATCH] Remove support for preloading on Windows --- ext/ffi/tests/300-win32.phpt | 24 ------- ext/ffi/tests/bug78761.phpt | 5 +- ext/opcache/ZendAccelerator.c | 69 ++----------------- ext/opcache/tests/bug78014.phpt | 5 +- ext/opcache/tests/bug78175.phpt | 5 +- ext/opcache/tests/bug78175_2.phpt | 5 +- ext/opcache/tests/bug78376.phpt | 7 +- ext/opcache/tests/bug78937_1.phpt | 5 +- ext/opcache/tests/bug78937_2.phpt | 7 +- ext/opcache/tests/bug78937_3.phpt | 5 +- ext/opcache/tests/bug78937_4.phpt | 7 +- ext/opcache/tests/bug78937_5.phpt | 7 +- ext/opcache/tests/bug78937_6.phpt | 5 +- ext/opcache/tests/preload_001.phpt | 5 +- ext/opcache/tests/preload_002.phpt | 5 +- ext/opcache/tests/preload_003.phpt | 5 +- ext/opcache/tests/preload_004.phpt | 5 +- ext/opcache/tests/preload_005.phpt | 5 +- ext/opcache/tests/preload_006.phpt | 1 + ext/opcache/tests/preload_007.phpt | 5 +- ext/opcache/tests/preload_008.phpt | 5 +- ext/opcache/tests/preload_009.phpt | 5 +- ext/opcache/tests/preload_010.phpt | 5 +- ext/opcache/tests/preload_011.phpt | 5 +- ext/opcache/tests/preload_012.phpt | 5 +- ext/opcache/tests/preload_013.phpt | 5 +- ext/opcache/tests/preload_class_alias.phpt | 5 +- ext/opcache/tests/preload_class_alias_2.phpt | 5 +- .../tests/preload_loadable_classes_1.phpt | 5 +- .../tests/preload_loadable_classes_2.phpt | 5 +- .../tests/preload_loadable_classes_3.phpt | 5 +- .../tests/preload_loadable_classes_4.inc | 3 - .../tests/preload_loadable_classes_4.phpt | 16 ----- ext/opcache/tests/preload_trait_static.phpt | 5 +- .../tests/preload_unresolved_prop_type.phpt | 5 +- ext/opcache/tests/preload_windows.phpt | 16 +++++ 36 files changed, 146 insertions(+), 141 deletions(-) delete mode 100644 ext/ffi/tests/300-win32.phpt delete mode 100644 ext/opcache/tests/preload_loadable_classes_4.inc delete mode 100644 ext/opcache/tests/preload_loadable_classes_4.phpt create mode 100644 ext/opcache/tests/preload_windows.phpt diff --git a/ext/ffi/tests/300-win32.phpt b/ext/ffi/tests/300-win32.phpt deleted file mode 100644 index 9fd9fac4c4bd9..0000000000000 --- a/ext/ffi/tests/300-win32.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -FFI 300: FFI preloading on Windows ---SKIPIF-- - - - ---INI-- -ffi.enable=1 -opcache.enable=1 -opcache.enable_cli=1 -opcache.optimization_level=-1 -opcache.preload={PWD}/preload.inc ---FILE-- -php_printf("Hello World from %s!\n", "PHP"); -?> ---CLEAN-- - ---EXPECT-- -Hello World from PHP! diff --git a/ext/ffi/tests/bug78761.phpt b/ext/ffi/tests/bug78761.phpt index 1db977a841c3e..0e6ae1b3b84f1 100644 --- a/ext/ffi/tests/bug78761.phpt +++ b/ext/ffi/tests/bug78761.phpt @@ -1,7 +1,10 @@ --TEST-- Bug #78761 (Zend memory heap corruption with preload and casting) --SKIPIF-- - + --INI-- opcache.enable_cli=1 opcache.preload={PWD}/bug78761_preload.php diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 1cb21cd13031d..e19980ab05bd8 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3397,13 +3397,6 @@ static void get_unlinked_dependency(zend_class_entry *ce, const char **kind, con *name = ZSTR_VAL(ce->parent_name); return; } -#ifdef ZEND_WIN32 - if (p->type == ZEND_INTERNAL_CLASS) { - *kind = "Windows can't link to internal parent "; - *name = ZSTR_VAL(ce->parent_name); - return; - } -#endif if (!(p->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { *kind = "Parent with unresolved initializers "; *name = ZSTR_VAL(ce->parent_name); @@ -3523,13 +3516,6 @@ static zend_bool preload_try_resolve_property_types(zend_class_entry *ce) continue; } if (p != ce) { -#ifdef ZEND_WIN32 - /* On Windows we can't link with internal class, because of ASLR */ - if (p->type == ZEND_INTERNAL_CLASS) { - ok = 0; - continue; - } -#endif if (!(p->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { ok = 0; continue; @@ -3666,10 +3652,6 @@ static void preload_link(void) parent = zend_hash_find_ptr(EG(class_table), key); zend_string_release(key); if (!parent) continue; -#ifdef ZEND_WIN32 - /* On Windows we can't link with internal class, because of ASLR */ - if (parent->type == ZEND_INTERNAL_CLASS) continue; -#endif if (!(parent->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { continue; } @@ -3686,13 +3668,6 @@ static void preload_link(void) found = 0; break; } -#ifdef ZEND_WIN32 - /* On Windows we can't link with internal class, because of ASLR */ - if (p->type == ZEND_INTERNAL_CLASS) { - found = 0; - break; - } -#endif if (!(p->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { found = 0; break; @@ -3709,13 +3684,6 @@ static void preload_link(void) found = 0; break; } -#ifdef ZEND_WIN32 - /* On Windows we can't link with internal class, because of ASLR */ - if (p->type == ZEND_INTERNAL_CLASS) { - found = 0; - break; - } -#endif } if (!found) continue; } @@ -3859,26 +3827,6 @@ static void preload_link(void) } ZEND_HASH_FOREACH_END(); } -#ifdef ZEND_WIN32 -static void preload_check_windows_restriction(zend_class_entry *scope, zend_class_entry *ce) { - if (ce && ce->type == ZEND_INTERNAL_CLASS) { - zend_error_noreturn(E_ERROR, - "Class %s uses internal class %s during preloading, which is not supported on Windows", - ZSTR_VAL(scope->name), ZSTR_VAL(ce->name)); - } -} - -static void preload_check_windows_restrictions(zend_class_entry *scope) { - uint32_t i; - - preload_check_windows_restriction(scope, scope->parent); - - for (i = 0; i < scope->num_interfaces; i++) { - preload_check_windows_restriction(scope, scope->interfaces[i]); - } -} -#endif - static inline int preload_update_class_constants(zend_class_entry *ce) { /* This is a separate function to work around what appears to be a bug in GCC * maybe-uninitialized analysis. */ @@ -3931,10 +3879,6 @@ static void preload_ensure_classes_loadable() { continue; } -#ifdef ZEND_WIN32 - preload_check_windows_restrictions(ce); -#endif - if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { if (preload_update_class_constants(ce) == FAILURE) { zend_error_noreturn(E_ERROR, @@ -4601,9 +4545,11 @@ static int accel_finish_startup(void) } if (ZCG(accel_directives).preload && *ZCG(accel_directives).preload) { -#ifndef ZEND_WIN32 +#ifdef ZEND_WIN32 + zend_accel_error(ACCEL_LOG_ERROR, "Preloading is not supported on Windows"); + return FAILURE; +#else int in_child = 0; -#endif int ret = SUCCESS; int rc; int orig_error_reporting; @@ -4637,7 +4583,6 @@ static int accel_finish_startup(void) return SUCCESS; } -#ifndef ZEND_WIN32 if (geteuid() == 0) { pid_t pid; struct passwd *pw; @@ -4701,7 +4646,6 @@ static int accel_finish_startup(void) zend_accel_error(ACCEL_LOG_WARNING, "\"opcache.preload_user\" is ignored"); } } -#endif sapi_module.activate = NULL; sapi_module.deactivate = NULL; @@ -4713,11 +4657,9 @@ static int accel_finish_startup(void) sapi_module.ub_write = preload_ub_write; sapi_module.flush = preload_flush; -#ifndef ZEND_WIN32 if (in_child) { CG(compiler_options) |= ZEND_COMPILE_PRELOAD_IN_CHILD; } -#endif CG(compiler_options) |= ZEND_COMPILE_PRELOAD; CG(compiler_options) |= ZEND_COMPILE_HANDLE_OP_ARRAY; CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES; @@ -4792,7 +4734,6 @@ static int accel_finish_startup(void) sapi_activate(); -#ifndef ZEND_WIN32 if (in_child) { if (ret == SUCCESS) { exit(0); @@ -4800,9 +4741,9 @@ static int accel_finish_startup(void) exit(2); } } -#endif return ret; +#endif } return SUCCESS; diff --git a/ext/opcache/tests/bug78014.phpt b/ext/opcache/tests/bug78014.phpt index 14f205e7b890e..47ec05977c9ce 100644 --- a/ext/opcache/tests/bug78014.phpt +++ b/ext/opcache/tests/bug78014.phpt @@ -6,7 +6,10 @@ opcache.enable_cli=1 opcache.optimization_level=-1 opcache.preload={PWD}/preload_bug78014.inc --SKIPIF-- - + --FILE-- + --FILE-- OK --EXPECT-- diff --git a/ext/opcache/tests/bug78175_2.phpt b/ext/opcache/tests/bug78175_2.phpt index 1d736f6e106e3..7b5ad850ae2cc 100644 --- a/ext/opcache/tests/bug78175_2.phpt +++ b/ext/opcache/tests/bug78175_2.phpt @@ -6,7 +6,10 @@ opcache.enable_cli=1 opcache.optimization_level=-1 opcache.preload={PWD}/preload_bug78175_2.inc --SKIPIF-- - + --FILE-- + --FILE-- --EXPECT-- -string(4) "aaaa" \ No newline at end of file +string(4) "aaaa" diff --git a/ext/opcache/tests/bug78937_1.phpt b/ext/opcache/tests/bug78937_1.phpt index 1125ad4eb0436..bc285f107b98d 100644 --- a/ext/opcache/tests/bug78937_1.phpt +++ b/ext/opcache/tests/bug78937_1.phpt @@ -6,7 +6,10 @@ opcache.enable_cli=1 opcache.optimization_level=-1 opcache.preload={PWD}/preload_bug78937.inc --SKIPIF-- - + --FILE-- + --FILE-- + --FILE-- + --FILE-- + --FILE-- + --FILE-- + --FILE-- + --FILE-- getPrototype()->class); diff --git a/ext/opcache/tests/preload_003.phpt b/ext/opcache/tests/preload_003.phpt index b8083879670ab..9ecec31aaed37 100644 --- a/ext/opcache/tests/preload_003.phpt +++ b/ext/opcache/tests/preload_003.phpt @@ -6,7 +6,10 @@ opcache.enable_cli=1 opcache.optimization_level=-1 opcache.preload={PWD}/preload.inc --SKIPIF-- - + --FILE-- + --FILE-- + --FILE-- --FILE-- diff --git a/ext/opcache/tests/preload_007.phpt b/ext/opcache/tests/preload_007.phpt index 2054cd8740d73..79c2a6737a4de 100644 --- a/ext/opcache/tests/preload_007.phpt +++ b/ext/opcache/tests/preload_007.phpt @@ -6,7 +6,10 @@ opcache.enable_cli=1 opcache.optimization_level=-1 opcache.preload={PWD}/preload_include.inc --SKIPIF-- - + --FILE-- + --FILE-- + --FILE-- + --FILE-- prop); diff --git a/ext/opcache/tests/preload_011.phpt b/ext/opcache/tests/preload_011.phpt index 32863398a952f..59be0493b48b4 100644 --- a/ext/opcache/tests/preload_011.phpt +++ b/ext/opcache/tests/preload_011.phpt @@ -6,7 +6,10 @@ opcache.enable_cli=1 opcache.optimization_level=-1 opcache.preload={PWD}/preload_variance_ind.inc --SKIPIF-- - + --FILE-- + --FILE-- ===DONE=== --EXPECTF-- diff --git a/ext/opcache/tests/preload_013.phpt b/ext/opcache/tests/preload_013.phpt index f6387c08e1238..925a1fc5ef9a9 100644 --- a/ext/opcache/tests/preload_013.phpt +++ b/ext/opcache/tests/preload_013.phpt @@ -7,7 +7,10 @@ opcache.optimization_level=-1 opcache.preload={PWD}/preload_nested_function.inc opcache.interned_strings_buffer=0 --SKIPIF-- - + --FILE-- + --FILE-- + --FILE-- + --FILE-- + --FILE-- Unreachable --EXPECTF-- diff --git a/ext/opcache/tests/preload_loadable_classes_3.phpt b/ext/opcache/tests/preload_loadable_classes_3.phpt index a48692960a683..78efb1680469c 100644 --- a/ext/opcache/tests/preload_loadable_classes_3.phpt +++ b/ext/opcache/tests/preload_loadable_classes_3.phpt @@ -6,7 +6,10 @@ opcache.enable_cli=1 opcache.optimization_level=-1 opcache.preload={PWD}/preload_loadable_classes_3.inc --SKIPIF-- - + --FILE-- Unreachable --EXPECTF-- diff --git a/ext/opcache/tests/preload_loadable_classes_4.inc b/ext/opcache/tests/preload_loadable_classes_4.inc deleted file mode 100644 index 162de6eab2447..0000000000000 --- a/ext/opcache/tests/preload_loadable_classes_4.inc +++ /dev/null @@ -1,3 +0,0 @@ - ---FILE-- -Unreachable ---EXPECTF-- -Fatal error: Class Test uses internal class Exception during preloading, which is not supported on Windows in Unknown on line 0 diff --git a/ext/opcache/tests/preload_trait_static.phpt b/ext/opcache/tests/preload_trait_static.phpt index 55e3a2cd8a4fe..c767ad6a9b36a 100644 --- a/ext/opcache/tests/preload_trait_static.phpt +++ b/ext/opcache/tests/preload_trait_static.phpt @@ -6,7 +6,10 @@ opcache.enable_cli=1 opcache.optimization_level=-1 opcache.preload={PWD}/preload_trait_static.inc --SKIPIF-- - + --FILE-- + --FILE-- ===DONE=== --EXPECTF-- diff --git a/ext/opcache/tests/preload_windows.phpt b/ext/opcache/tests/preload_windows.phpt new file mode 100644 index 0000000000000..0414cfa0b53c4 --- /dev/null +++ b/ext/opcache/tests/preload_windows.phpt @@ -0,0 +1,16 @@ +--TEST-- +Preloading is not supported on Windows +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.preload={PWD}/preload.inc +--SKIPIF-- + +--FILE-- +Unreachable +--EXPECTF-- +%s: Error Preloading is not supported on Windows