Skip to content

Commit 9b6c0bd

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Remove support for preloading on Windows
2 parents b22daa3 + 59c3dda commit 9b6c0bd

36 files changed

+146
-140
lines changed

ext/ffi/tests/300-win32.phpt

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

ext/ffi/tests/bug78761.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
--TEST--
22
Bug #78761 (Zend memory heap corruption with preload and casting)
33
--SKIPIF--
4-
<?php require_once('skipif.inc'); ?>
4+
<?php
5+
require_once('skipif.inc');
6+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
7+
?>
58
--INI--
69
opcache.enable_cli=1
710
opcache.preload={PWD}/bug78761_preload.php

ext/opcache/ZendAccelerator.c

Lines changed: 5 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,13 +3462,6 @@ static void get_unlinked_dependency(zend_class_entry *ce, const char **kind, con
34623462
*name = ZSTR_VAL(ce->parent_name);
34633463
return;
34643464
}
3465-
#ifdef ZEND_WIN32
3466-
if (p->type == ZEND_INTERNAL_CLASS) {
3467-
*kind = "Windows can't link to internal parent ";
3468-
*name = ZSTR_VAL(ce->parent_name);
3469-
return;
3470-
}
3471-
#endif
34723465
if (!(p->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
34733466
*kind = "Parent with unresolved initializers ";
34743467
*name = ZSTR_VAL(ce->parent_name);
@@ -3576,12 +3569,6 @@ static zend_class_entry *preload_fetch_resolved_ce(zend_string *name, zend_class
35763569
/* Ignore the following requirements if this is the class referring to itself */
35773570
return ce;
35783571
}
3579-
#ifdef ZEND_WIN32
3580-
/* On Windows we can't link with internal class, because of ASLR */
3581-
if (ce->type == ZEND_INTERNAL_CLASS) {
3582-
return NULL;
3583-
}
3584-
#endif
35853572
if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
35863573
return NULL;
35873574
}
@@ -3752,10 +3739,6 @@ static void preload_link(void)
37523739
parent = zend_hash_find_ptr(EG(class_table), key);
37533740
zend_string_release(key);
37543741
if (!parent) continue;
3755-
#ifdef ZEND_WIN32
3756-
/* On Windows we can't link with internal class, because of ASLR */
3757-
if (parent->type == ZEND_INTERNAL_CLASS) continue;
3758-
#endif
37593742
if (!(parent->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
37603743
continue;
37613744
}
@@ -3772,13 +3755,6 @@ static void preload_link(void)
37723755
found = 0;
37733756
break;
37743757
}
3775-
#ifdef ZEND_WIN32
3776-
/* On Windows we can't link with internal class, because of ASLR */
3777-
if (p->type == ZEND_INTERNAL_CLASS) {
3778-
found = 0;
3779-
break;
3780-
}
3781-
#endif
37823758
if (!(p->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
37833759
found = 0;
37843760
break;
@@ -3795,13 +3771,6 @@ static void preload_link(void)
37953771
found = 0;
37963772
break;
37973773
}
3798-
#ifdef ZEND_WIN32
3799-
/* On Windows we can't link with internal class, because of ASLR */
3800-
if (p->type == ZEND_INTERNAL_CLASS) {
3801-
found = 0;
3802-
break;
3803-
}
3804-
#endif
38053774
}
38063775
if (!found) continue;
38073776
}
@@ -3945,26 +3914,6 @@ static void preload_link(void)
39453914
} ZEND_HASH_FOREACH_END();
39463915
}
39473916

3948-
#ifdef ZEND_WIN32
3949-
static void preload_check_windows_restriction(zend_class_entry *scope, zend_class_entry *ce) {
3950-
if (ce && ce->type == ZEND_INTERNAL_CLASS) {
3951-
zend_error_noreturn(E_ERROR,
3952-
"Class %s uses internal class %s during preloading, which is not supported on Windows",
3953-
ZSTR_VAL(scope->name), ZSTR_VAL(ce->name));
3954-
}
3955-
}
3956-
3957-
static void preload_check_windows_restrictions(zend_class_entry *scope) {
3958-
uint32_t i;
3959-
3960-
preload_check_windows_restriction(scope, scope->parent);
3961-
3962-
for (i = 0; i < scope->num_interfaces; i++) {
3963-
preload_check_windows_restriction(scope, scope->interfaces[i]);
3964-
}
3965-
}
3966-
#endif
3967-
39683917
static inline int preload_update_class_constants(zend_class_entry *ce) {
39693918
/* This is a separate function to work around what appears to be a bug in GCC
39703919
* maybe-uninitialized analysis. */
@@ -4017,10 +3966,6 @@ static void preload_ensure_classes_loadable() {
40173966
continue;
40183967
}
40193968

4020-
#ifdef ZEND_WIN32
4021-
preload_check_windows_restrictions(ce);
4022-
#endif
4023-
40243969
if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
40253970
if (preload_update_class_constants(ce) == FAILURE) {
40263971
zend_error_noreturn(E_ERROR,
@@ -4698,9 +4643,11 @@ static int accel_finish_startup(void)
46984643
}
46994644

47004645
if (ZCG(accel_directives).preload && *ZCG(accel_directives).preload) {
4701-
#ifndef ZEND_WIN32
4646+
#ifdef ZEND_WIN32
4647+
zend_accel_error(ACCEL_LOG_ERROR, "Preloading is not supported on Windows");
4648+
return FAILURE;
4649+
#else
47024650
int in_child = 0;
4703-
#endif
47044651
int ret = SUCCESS;
47054652
int rc;
47064653
int orig_error_reporting;
@@ -4734,7 +4681,6 @@ static int accel_finish_startup(void)
47344681
return SUCCESS;
47354682
}
47364683

4737-
#ifndef ZEND_WIN32
47384684
if (geteuid() == 0) {
47394685
pid_t pid;
47404686
struct passwd *pw;
@@ -4798,7 +4744,6 @@ static int accel_finish_startup(void)
47984744
zend_accel_error(ACCEL_LOG_WARNING, "\"opcache.preload_user\" is ignored");
47994745
}
48004746
}
4801-
#endif
48024747

48034748
sapi_module.activate = NULL;
48044749
sapi_module.deactivate = NULL;
@@ -4810,11 +4755,9 @@ static int accel_finish_startup(void)
48104755
sapi_module.ub_write = preload_ub_write;
48114756
sapi_module.flush = preload_flush;
48124757

4813-
#ifndef ZEND_WIN32
48144758
if (in_child) {
48154759
CG(compiler_options) |= ZEND_COMPILE_PRELOAD_IN_CHILD;
48164760
}
4817-
#endif
48184761
CG(compiler_options) |= ZEND_COMPILE_PRELOAD;
48194762
CG(compiler_options) |= ZEND_COMPILE_HANDLE_OP_ARRAY;
48204763
CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES;
@@ -4889,17 +4832,16 @@ static int accel_finish_startup(void)
48894832

48904833
sapi_activate();
48914834

4892-
#ifndef ZEND_WIN32
48934835
if (in_child) {
48944836
if (ret == SUCCESS) {
48954837
exit(0);
48964838
} else {
48974839
exit(2);
48984840
}
48994841
}
4900-
#endif
49014842

49024843
return ret;
4844+
#endif
49034845
}
49044846

49054847
return SUCCESS;

ext/opcache/tests/bug78014.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_bug78014.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
class B extends A {

ext/opcache/tests/bug78175.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_bug78175.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
OK
1215
--EXPECT--

ext/opcache/tests/bug78175_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_bug78175_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(get_class(Loader::getLoader()));

ext/opcache/tests/bug78376.phpt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_bug78376.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(\A::$a);
1316
?>
1417
--EXPECT--
15-
string(4) "aaaa"
18+
string(4) "aaaa"

ext/opcache/tests/bug78937_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_bug78937.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
class Bar {

ext/opcache/tests/bug78937_2.phpt

Lines changed: 5 additions & 2 deletions
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_bug78937.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
include(__DIR__ . "/preload_bug78937.inc");
@@ -19,4 +22,4 @@ Warning: Can't preload unlinked class Foo: Unknown parent Bar in %spreload_bug78
1922

2023
Warning: Can't preload unlinked class class@anonymous: Unknown parent Bar in %spreload_bug78937.inc on line 3
2124
object(class@anonymous)#%d (0) {
22-
}
25+
}

ext/opcache/tests/bug78937_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_bug78937.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
include(__DIR__ . "/preload_bug78937.inc");

ext/opcache/tests/bug78937_4.phpt

Lines changed: 5 additions & 2 deletions
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_bug78937.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
class Bar {
@@ -19,4 +22,4 @@ Warning: Can't preload unlinked class Foo: Unknown parent Bar in %spreload_bug78
1922

2023
Warning: Can't preload unlinked class class@anonymous: Unknown parent Bar in %spreload_bug78937.inc on line 3
2124

22-
Fatal error: Class foo wasn't preloaded in %spreload_bug78937.inc on line 6
25+
Fatal error: Class foo wasn't preloaded in %spreload_bug78937.inc on line 6

ext/opcache/tests/bug78937_5.phpt

Lines changed: 5 additions & 2 deletions
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_bug78937.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
include(__DIR__ . "/preload_bug78937.inc");
@@ -20,4 +23,4 @@ Warning: Can't preload unlinked class Foo: Unknown parent Bar in %spreload_bug78
2023

2124
Warning: Can't preload unlinked class class@anonymous: Unknown parent Bar in %spreload_bug78937.inc on line 3
2225
object(Foo)#%d (0) {
23-
}
26+
}

ext/opcache/tests/bug78937_6.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_bug78937.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
include(__DIR__ . "/preload_bug78937.inc");

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'));

0 commit comments

Comments
 (0)