Skip to content

Commit 107f04e

Browse files
committed
Remove support for preloading on Windows
1 parent d6f86ca commit 107f04e

22 files changed

+90
-100
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,13 +3389,6 @@ static void get_unlinked_dependency(zend_class_entry *ce, const char **kind, con
33893389
*name = ZSTR_VAL(ce->parent_name);
33903390
return;
33913391
}
3392-
#ifdef ZEND_WIN32
3393-
if (p->type == ZEND_INTERNAL_CLASS) {
3394-
*kind = "Windows can't link to internal parent ";
3395-
*name = ZSTR_VAL(ce->parent_name);
3396-
return;
3397-
}
3398-
#endif
33993392
if (!(p->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
34003393
*kind = "Parent with unresolved initializers ";
34013394
*name = ZSTR_VAL(ce->parent_name);
@@ -3515,13 +3508,6 @@ static zend_bool preload_try_resolve_property_types(zend_class_entry *ce)
35153508
continue;
35163509
}
35173510
if (p != ce) {
3518-
#ifdef ZEND_WIN32
3519-
/* On Windows we can't link with internal class, because of ASLR */
3520-
if (p->type == ZEND_INTERNAL_CLASS) {
3521-
ok = 0;
3522-
continue;
3523-
}
3524-
#endif
35253511
if (!(p->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
35263512
ok = 0;
35273513
continue;
@@ -3658,10 +3644,6 @@ static void preload_link(void)
36583644
parent = zend_hash_find_ptr(EG(class_table), key);
36593645
zend_string_release(key);
36603646
if (!parent) continue;
3661-
#ifdef ZEND_WIN32
3662-
/* On Windows we can't link with internal class, because of ASLR */
3663-
if (parent->type == ZEND_INTERNAL_CLASS) continue;
3664-
#endif
36653647
if (!(parent->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
36663648
continue;
36673649
}
@@ -3678,13 +3660,6 @@ static void preload_link(void)
36783660
found = 0;
36793661
break;
36803662
}
3681-
#ifdef ZEND_WIN32
3682-
/* On Windows we can't link with internal class, because of ASLR */
3683-
if (p->type == ZEND_INTERNAL_CLASS) {
3684-
found = 0;
3685-
break;
3686-
}
3687-
#endif
36883663
if (!(p->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
36893664
found = 0;
36903665
break;
@@ -3701,13 +3676,6 @@ static void preload_link(void)
37013676
found = 0;
37023677
break;
37033678
}
3704-
#ifdef ZEND_WIN32
3705-
/* On Windows we can't link with internal class, because of ASLR */
3706-
if (p->type == ZEND_INTERNAL_CLASS) {
3707-
found = 0;
3708-
break;
3709-
}
3710-
#endif
37113679
}
37123680
if (!found) continue;
37133681
}
@@ -3850,26 +3818,6 @@ static void preload_link(void)
38503818
} ZEND_HASH_FOREACH_END();
38513819
}
38523820

3853-
#ifdef ZEND_WIN32
3854-
static void preload_check_windows_restriction(zend_class_entry *scope, zend_class_entry *ce) {
3855-
if (ce && ce->type == ZEND_INTERNAL_CLASS) {
3856-
zend_error_noreturn(E_ERROR,
3857-
"Class %s uses internal class %s during preloading, which is not supported on Windows",
3858-
ZSTR_VAL(scope->name), ZSTR_VAL(ce->name));
3859-
}
3860-
}
3861-
3862-
static void preload_check_windows_restrictions(zend_class_entry *scope) {
3863-
uint32_t i;
3864-
3865-
preload_check_windows_restriction(scope, scope->parent);
3866-
3867-
for (i = 0; i < scope->num_interfaces; i++) {
3868-
preload_check_windows_restriction(scope, scope->interfaces[i]);
3869-
}
3870-
}
3871-
#endif
3872-
38733821
static inline int preload_update_class_constants(zend_class_entry *ce) {
38743822
/* This is a separate function to work around what appears to be a bug in GCC
38753823
* maybe-uninitialized analysis. */
@@ -3919,10 +3867,6 @@ static void preload_ensure_classes_loadable() {
39193867
continue;
39203868
}
39213869

3922-
#ifdef ZEND_WIN32
3923-
preload_check_windows_restrictions(ce);
3924-
#endif
3925-
39263870
if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
39273871
if (preload_update_class_constants(ce) == FAILURE) {
39283872
zend_error_noreturn(E_ERROR,
@@ -4589,9 +4533,11 @@ static int accel_finish_startup(void)
45894533
}
45904534

45914535
if (ZCG(accel_directives).preload && *ZCG(accel_directives).preload) {
4592-
#ifndef ZEND_WIN32
4536+
#ifdef ZEND_WIN32
4537+
zend_accel_error(ACCEL_LOG_ERROR, "Preloading is not supported on Windows");
4538+
return FAILURE;
4539+
#else
45934540
int in_child = 0;
4594-
#endif
45954541
int ret = SUCCESS;
45964542
int rc;
45974543
int orig_error_reporting;
@@ -4625,7 +4571,6 @@ static int accel_finish_startup(void)
46254571
return SUCCESS;
46264572
}
46274573

4628-
#ifndef ZEND_WIN32
46294574
if (geteuid() == 0) {
46304575
pid_t pid;
46314576
struct passwd *pw;
@@ -4689,7 +4634,6 @@ static int accel_finish_startup(void)
46894634
zend_accel_error(ACCEL_LOG_WARNING, "\"opcache.preload_user\" is ignored");
46904635
}
46914636
}
4692-
#endif
46934637

46944638
sapi_module.activate = NULL;
46954639
sapi_module.deactivate = NULL;
@@ -4701,11 +4645,9 @@ static int accel_finish_startup(void)
47014645
sapi_module.ub_write = preload_ub_write;
47024646
sapi_module.flush = preload_flush;
47034647

4704-
#ifndef ZEND_WIN32
47054648
if (in_child) {
47064649
CG(compiler_options) |= ZEND_COMPILE_PRELOAD_IN_CHILD;
47074650
}
4708-
#endif
47094651
CG(compiler_options) |= ZEND_COMPILE_PRELOAD;
47104652
CG(compiler_options) |= ZEND_COMPILE_HANDLE_OP_ARRAY;
47114653
CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES;
@@ -4780,17 +4722,16 @@ static int accel_finish_startup(void)
47804722

47814723
sapi_activate();
47824724

4783-
#ifndef ZEND_WIN32
47844725
if (in_child) {
47854726
if (ret == SUCCESS) {
47864727
exit(0);
47874728
} else {
47884729
exit(2);
47894730
}
47904731
}
4791-
#endif
47924732

47934733
return ret;
4734+
#endif
47944735
}
47954736

47964737
return SUCCESS;

ext/opcache/tests/preload_001.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
var_dump(function_exists("f1"));

ext/opcache/tests/preload_002.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
var_dump((new ReflectionMethod('x', 'foo'))->getPrototype()->class);

ext/opcache/tests/preload_003.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
Y::foo();

ext/opcache/tests/preload_004.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_undef_const.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
var_dump(class_exists('Foo'));

ext/opcache/tests/preload_005.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_globals.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
$x = 123;

ext/opcache/tests/preload_006.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ opcache.preload={PWD}/preload_inheritance_error_ind.inc
88
--SKIPIF--
99
<?php
1010
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
1112
if (getenv('SKIP_ASAN')) die('xfail Startup failure leak');
1213
?>
1314
--FILE--

ext/opcache/tests/preload_007.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_include.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
echo "Foobar";

ext/opcache/tests/preload_008.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
var_dump(get_anon());

ext/opcache/tests/preload_009.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_undef_const_2.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
var_dump(trait_exists('T'));

ext/opcache/tests/preload_010.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_overwritten_prop_init.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
var_dump((new Bar)->prop);

ext/opcache/tests/preload_011.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_variance_ind.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
interface K {}

ext/opcache/tests/preload_012.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_const_autoload.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
===DONE===
1215
--EXPECTF--

ext/opcache/tests/preload_013.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_nested_function.inc
88
opcache.interned_strings_buffer=0
99
--SKIPIF--
10-
<?php require_once('skipif.inc'); ?>
10+
<?php
11+
require_once('skipif.inc');
12+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
13+
?>
1114
--FILE--
1215
<?php
1316
test();

ext/opcache/tests/preload_class_alias.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_class_alias.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
var_dump(class_exists('A'));

ext/opcache/tests/preload_loadable_classes_1.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_loadable_classes_1.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
<?php
1215
var_dump(class_exists('Test'));

ext/opcache/tests/preload_loadable_classes_2.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_loadable_classes_2.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
Unreachable
1215
--EXPECTF--

ext/opcache/tests/preload_loadable_classes_3.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_loadable_classes_3.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
Unreachable
1215
--EXPECTF--

ext/opcache/tests/preload_loadable_classes_4.inc

Lines changed: 0 additions & 3 deletions
This file was deleted.

ext/opcache/tests/preload_loadable_classes_4.phpt

Lines changed: 0 additions & 16 deletions
This file was deleted.

ext/opcache/tests/preload_unresolved_prop_type.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_unresolved_prop_type.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
1013
--FILE--
1114
===DONE===
1215
--EXPECTF--

0 commit comments

Comments
 (0)