Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3702f97
opcache_get_configuration() properly reports jit_prof_threshold
cmb69 Dec 7, 2024
5eed224
Merge branch 'PHP-8.3' into PHP-8.4
cmb69 Dec 9, 2024
e5b4743
Merge branch 'PHP-8.4'
cmb69 Dec 9, 2024
85731e8
[skip ci] Add nightly job for x64 Windows with ASan enabled
cmb69 Dec 8, 2024
0373157
Fix GH-16843: Windows phpize builds ignore source subfolders
cmb69 Dec 2, 2024
3bea6a2
ext/sockets: socket_strerror follow-up on GH-16267 fix.
devnexen Nov 28, 2024
986dfd4
Merge branch 'PHP-8.3' into PHP-8.4
devnexen Dec 9, 2024
94d9cc1
Merge branch 'PHP-8.4'
devnexen Dec 9, 2024
e675c1a
Drop intl on macOS + PHP 8.1 build
iluuu1994 Dec 9, 2024
40517d0
Merge branch 'PHP-8.1' into PHP-8.2
iluuu1994 Dec 9, 2024
bf0d440
Merge branch 'PHP-8.2' into PHP-8.3
iluuu1994 Dec 9, 2024
c52beea
Merge branch 'PHP-8.3' into PHP-8.4
iluuu1994 Dec 9, 2024
067a17d
Merge branch 'PHP-8.4'
iluuu1994 Dec 9, 2024
b0b39cd
Backport JIT fix: set valid EX(opline) before calling gc_possible_roo…
dstogov Nov 19, 2024
483f265
Merge branch 'PHP-8.1' into PHP-8.2
iluuu1994 Dec 9, 2024
d9aa27e
Merge branch 'PHP-8.2' into PHP-8.3
iluuu1994 Dec 9, 2024
7b5141b
Merge branch 'PHP-8.3' into PHP-8.4
iluuu1994 Dec 9, 2024
670f78f
Merge branch 'PHP-8.4'
iluuu1994 Dec 9, 2024
8491730
Fix duplicate dynamic properties in hooked object iterator properties…
iluuu1994 Dec 8, 2024
f11d9b5
Merge branch 'PHP-8.4'
iluuu1994 Dec 9, 2024
792f63d
Fix unstable get_iterator pointer for hooked classes in shm on Windows
iluuu1994 Dec 3, 2024
fbb97aa
Merge branch 'PHP-8.4'
iluuu1994 Dec 9, 2024
5a482a1
Fix enum to bool comparison
iluuu1994 Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/scripts/windows/build_task.bat
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ if %errorlevel% neq 0 exit /b 3

if "%THREAD_SAFE%" equ "0" set ADD_CONF=%ADD_CONF% --disable-zts
if "%INTRINSICS%" neq "" set ADD_CONF=%ADD_CONF% --enable-native-intrinsics=%INTRINSICS%
if "%ASAN%" equ "1" set ADD_CONF=%ADD_CONF% --enable-sanitizer --enable-debug-pack

set CFLAGS=/W1 /WX /w14013

Expand Down
4 changes: 3 additions & 1 deletion .github/scripts/windows/test_task.bat
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ for %%i in (ldap) do (

set TEST_PHPDBG_EXECUTABLE=%PHP_BUILD_DIR%\phpdbg.exe

if "%ASAN%" equ "1" set ASAN_OPTS=--asan

mkdir c:\tests_tmp

nmake test TESTS="%OPCACHE_OPTS% -g FAIL,BORK,LEAK,XLEAK --no-progress -q --offline --show-diff --show-slow 1000 --set-timeout 120 --temp-source c:\tests_tmp --temp-target c:\tests_tmp %PARALLEL%"
nmake test TESTS="%OPCACHE_OPTS% -g FAIL,BORK,LEAK,XLEAK %ASAN_OPTS% --no-progress -q --offline --show-diff --show-slow 1000 --set-timeout 120 --temp-source c:\tests_tmp --temp-target c:\tests_tmp %PARALLEL%"

set EXIT_CODE=%errorlevel%

Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -963,10 +963,18 @@ jobs:
- x64: true
zts: true
opcache: true
asan: false
- x64: false
zts: false
opcache: false
name: "WINDOWS_${{ matrix.x64 && 'X64' || 'X86' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
asan: false
- x64: true
zts: true
opcache: true
asan: true
branch: 'master'
timeout: 120
name: "WINDOWS_${{ matrix.x64 && 'X64' || 'X86' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || ''}}"
runs-on: windows-${{ inputs.windows_version }}
env:
PHP_BUILD_CACHE_BASE_DIR: C:\build-cache
Expand All @@ -979,6 +987,7 @@ jobs:
INTRINSICS: "${{ matrix.zts && 'AVX2' || '' }}"
PARALLEL: -j2
OPCACHE: "${{ matrix.opcache && '1' || '0' }}"
ASAN: "${{ matrix.asan && '1' || '0' }}"
steps:
- name: git config
run: git config --global core.autocrlf false && git config --global core.eol lf
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ PHP NEWS
- Windows:
. Fixed bug GH-10992 (Improper long path support for relative paths). (cmb,
nielsdos)
. Fixed bug GH-16843 (Windows phpize builds ignore source subfolders). (cmb)

- XMLWriter:
. Improved performance and reduce memory consumption. (nielsdos)
Expand Down
10 changes: 10 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ PHP 8.5 UPGRADE NOTES
- Core:
. It is no longer possible to use "array" and "callable" as class alias names
in class_alias().
. Loosely comparing uncomparable objects (e.g. enums, \CurlHandle and other
internal classes) to booleans was previously inconsistent. If compared to a
boolean literal $object == true, it would behave the same way as (bool)
$object. If compared to a statically unknown value $object == $true, it
would always return false. This behavior was consolidated to always follow
the behavior of (bool) $object.

- Intl:
. The extension now requires at least ICU 57.1.
Expand Down Expand Up @@ -166,6 +172,10 @@ PHP 8.5 UPGRADE NOTES
PHP_RELEASE_VERSION are now always numbers. Previously, they have been
strings for buildconf builds.

* phpize builds now reflect the source tree in the build dir (like that already
worked for in-tree builds); some extension builds (especially when using
Makefile.frag.w32) may need adjustments.

* --enable-sanitzer is now supported for MSVC builds. This enables ASan and
debug assertions, and is supported as of MSVC 16.10 and Windows 10.

Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/enum/comparison.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
bool(true)
50 changes: 50 additions & 0 deletions Zend/tests/gh16954.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
--TEST--
GH-16954: Enum to bool comparison is inconsistent
--FILE--
<?php

enum E {
case C;
}

$true = true;
$false = false;

var_dump(E::C == true);
var_dump(E::C == $true);
var_dump(true == E::C);
var_dump($true == E::C);

var_dump(E::C != true);
var_dump(E::C != $true);
var_dump(true != E::C);
var_dump($true != E::C);

var_dump(E::C == false);
var_dump(E::C == $false);
var_dump(false == E::C);
var_dump($false == E::C);

var_dump(E::C != false);
var_dump(E::C != $false);
var_dump(false != E::C);
var_dump($false != E::C);

?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
20 changes: 20 additions & 0 deletions Zend/tests/property_hooks/oss-fuzz-382922236.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
OSS-Fuzz #382922236: Duplicate dynamic properties in hooked object iterator properties table
--FILE--
<?php

#[AllowDynamicProperties]
class C {
public $a {
get => 42;
}
}

$obj = new C();
$b = &$obj->b;
unset($b);
echo json_encode($obj);

?>
--EXPECT--
{"a":42,"b":null}
7 changes: 7 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -8598,10 +8598,13 @@ static void zend_compile_property_hooks(

ce->num_hooked_props++;

/* See zend_link_hooked_object_iter(). */
#ifndef ZEND_OPCACHE_SHM_REATTACHMENT
if (!ce->get_iterator) {
/* Will be removed again, in case of Iterator or IteratorAggregate. */
ce->get_iterator = zend_hooked_object_get_iterator;
}
#endif

if (!prop_info->ce->parent_name) {
zend_verify_hooked_property(ce, prop_info, prop_name);
Expand Down Expand Up @@ -9127,6 +9130,10 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)

/* We currently don't early-bind classes that implement interfaces or use traits */
if (!ce->num_interfaces && !ce->num_traits && !ce->num_hooked_prop_variance_checks
#ifdef ZEND_OPCACHE_SHM_REATTACHMENT
/* See zend_link_hooked_object_iter(). */
&& !ce->num_hooked_props
#endif
&& !(CG(compiler_options) & ZEND_COMPILE_WITHOUT_EXECUTION)) {
if (toplevel) {
if (extends_ast) {
Expand Down
31 changes: 30 additions & 1 deletion Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,27 @@ ZEND_API inheritance_status zend_verify_property_hook_variance(const zend_proper
return zend_perform_covariant_type_check(ce, prop_info->type, ce, value_arg_info->type);
}

#ifdef ZEND_OPCACHE_SHM_REATTACHMENT
/* Hooked properties set get_iterator, which causes issues on for shm
* reattachment. Avoid early-binding on Windows and set get_iterator during
* inheritance. The linked class may not use inheritance cache. */
static void zend_link_hooked_object_iter(zend_class_entry *ce) {
if (!ce->get_iterator && ce->num_hooked_props) {
ce->get_iterator = zend_hooked_object_get_iterator;
ce->ce_flags &= ~ZEND_ACC_CACHEABLE;
if (CG(current_linking_class) == ce) {
# if ZEND_DEBUG
/* This check is executed before inheriting any elements that can
* track dependencies. */
HashTable *ht = (HashTable*)ce->inheritance_cache;
ZEND_ASSERT(!ht);
# endif
CG(current_linking_class) = NULL;
}
}
}
#endif

ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *parent_ce, bool checked) /* {{{ */
{
zend_property_info *property_info;
Expand Down Expand Up @@ -3422,7 +3443,7 @@ static zend_class_entry *zend_lazy_class_load(zend_class_entry *pce)
return ce;
}

#ifndef ZEND_WIN32
#ifndef ZEND_OPCACHE_SHM_REATTACHMENT
# define UPDATE_IS_CACHEABLE(ce) do { \
if ((ce)->type == ZEND_USER_CLASS) { \
is_cacheable &= (ce)->ce_flags; \
Expand Down Expand Up @@ -3567,6 +3588,10 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
zend_enum_register_funcs(ce);
}

#ifdef ZEND_OPCACHE_SHM_REATTACHMENT
zend_link_hooked_object_iter(ce);
#endif

if (parent) {
if (!(parent->ce_flags & ZEND_ACC_LINKED)) {
add_dependency_obligation(ce, parent);
Expand Down Expand Up @@ -3855,6 +3880,10 @@ ZEND_API zend_class_entry *zend_try_early_bind(zend_class_entry *ce, zend_class_
zend_begin_record_errors();
}

#ifdef ZEND_OPCACHE_SHM_REATTACHMENT
zend_link_hooked_object_iter(ce);
#endif

zend_do_inheritance_ex(ce, parent_ce, status == INHERITANCE_SUCCESS);
if (parent_ce && parent_ce->num_interfaces) {
zend_do_inherit_interfaces(ce, parent_ce);
Expand Down
5 changes: 3 additions & 2 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2063,8 +2063,9 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */
object_lhs = false;
}
ZEND_ASSERT(Z_TYPE_P(value) != IS_OBJECT);
uint8_t target_type = (Z_TYPE_P(value) == IS_FALSE || Z_TYPE_P(value) == IS_TRUE)
? _IS_BOOL : Z_TYPE_P(value);
uint8_t target_type = Z_TYPE_P(value);
/* Should be handled in zend_compare(). */
ZEND_ASSERT(target_type != IS_FALSE && target_type != IS_TRUE);
if (Z_OBJ_HT_P(object)->cast_object(Z_OBJ_P(object), &casted, target_type) == FAILURE) {
// TODO: Less crazy.
if (target_type == IS_LONG || target_type == IS_DOUBLE) {
Expand Down
30 changes: 23 additions & 7 deletions Zend/zend_operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -2333,13 +2333,29 @@ ZEND_API int ZEND_FASTCALL zend_compare(zval *op1, zval *op2) /* {{{ */
}

if (Z_TYPE_P(op1) == IS_OBJECT
&& Z_TYPE_P(op2) == IS_OBJECT
&& Z_OBJ_P(op1) == Z_OBJ_P(op2)) {
return 0;
} else if (Z_TYPE_P(op1) == IS_OBJECT) {
return Z_OBJ_HANDLER_P(op1, compare)(op1, op2);
} else if (Z_TYPE_P(op2) == IS_OBJECT) {
return Z_OBJ_HANDLER_P(op2, compare)(op1, op2);
|| Z_TYPE_P(op2) == IS_OBJECT) {
zval *object, *other;
if (Z_TYPE_P(op1) == IS_OBJECT) {
object = op1;
other = op2;
} else {
object = op2;
other = op1;
}
if (EXPECTED(Z_TYPE_P(other) == IS_OBJECT)) {
if (Z_OBJ_P(object) == Z_OBJ_P(other)) {
return 0;
}
} else if (Z_TYPE_P(other) == IS_TRUE || Z_TYPE_P(other) == IS_FALSE) {
zval casted;
if (Z_OBJ_HANDLER_P(object, cast_object)(Z_OBJ_P(object), &casted, _IS_BOOL) == FAILURE) {
return object == op1 ? 1 : -1;
}
int ret = object == op1 ? zend_compare(&casted, other) : zend_compare(other, &casted);
ZEND_ASSERT(!Z_REFCOUNTED_P(&casted));
return ret;
}
return Z_OBJ_HANDLER_P(object, compare)(op1, op2);
}

if (!converted) {
Expand Down
7 changes: 7 additions & 0 deletions Zend/zend_portability.h
Original file line number Diff line number Diff line change
Expand Up @@ -865,4 +865,11 @@ static zend_always_inline uint64_t ZEND_BYTES_SWAP64(uint64_t u)
}
#endif

#ifdef ZEND_WIN32
/* Whether it's allowed to reattach to a shm segment from different processes on
* this platform. This prevents pointing to internal structures from shm due to
* ASLR. Currently only possible on Windows. */
# define ZEND_OPCACHE_SHM_REATTACHMENT 1
#endif

#endif /* ZEND_PORTABILITY_H */
7 changes: 5 additions & 2 deletions Zend/zend_property_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ static uint32_t zho_num_backed_props(zend_object *zobj)
static zend_array *zho_build_properties_ex(zend_object *zobj, bool check_access, bool force_ptr, bool include_dynamic_props)
{
zend_class_entry *ce = zobj->ce;
zend_array *properties = zend_new_array(ce->default_properties_count);
zend_array *properties = zend_new_array(include_dynamic_props && zobj->properties
? zend_hash_num_elements(zobj->properties)
: ce->default_properties_count);
zend_hash_real_init_mixed(properties);

/* Build list of parents */
Expand Down Expand Up @@ -105,7 +107,8 @@ static zend_array *zho_build_properties_ex(zend_object *zobj, bool check_access,
zend_string *prop_name;
zval *prop_value;
ZEND_HASH_FOREACH_STR_KEY_VAL_FROM(zobj->properties, prop_name, prop_value, zho_num_backed_props(zobj)) {
Z_TRY_ADDREF_P(_zend_hash_append(properties, prop_name, prop_value));
zval *tmp = _zend_hash_append(properties, prop_name, prop_value);
Z_TRY_ADDREF_P(tmp);
} ZEND_HASH_FOREACH_END();
}

Expand Down
6 changes: 6 additions & 0 deletions ext/opcache/tests/dump_property_hooks.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ opcache.enable_cli=1
opcache.opt_debug_level=0x20000
--EXTENSIONS--
opcache
--SKIPIF--
<?php
if (PHP_OS_FAMILY === 'Windows') {
die('skip Windows emits additional DECLARE_CLASS_DELAYED opcode');
}
?>
--FILE--
<?php

Expand Down
19 changes: 19 additions & 0 deletions ext/opcache/tests/opcache_jit_prof_threshold.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
opcache_get_configuration() properly reports jit_prof_threshold
--EXTENSIONS--
opcache
--SKIPIF--
<?php
if (!isset(opcache_get_configuration()["directives"]["opcache.jit_prof_threshold"])) die("skip no JIT");
?>
--FILE--
<?php
$expected = 1 / 128; // needs to be exactly representable as IEEE double
ini_set("opcache.jit_prof_threshold", $expected);
$actual = opcache_get_configuration()["directives"]["opcache.jit_prof_threshold"];
var_dump($actual);
var_dump($actual === $expected);
?>
--EXPECTF--
float(0.0078125)
bool(true)
2 changes: 1 addition & 1 deletion ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ ZEND_FUNCTION(opcache_get_configuration)
add_assoc_long(&directives, "opcache.jit_max_recursive_returns", JIT_G(max_recursive_returns));
add_assoc_long(&directives, "opcache.jit_max_root_traces", JIT_G(max_root_traces));
add_assoc_long(&directives, "opcache.jit_max_side_traces", JIT_G(max_side_traces));
add_assoc_long(&directives, "opcache.jit_prof_threshold", JIT_G(prof_threshold));
add_assoc_double(&directives, "opcache.jit_prof_threshold", JIT_G(prof_threshold));
add_assoc_long(&directives, "opcache.jit_max_trace_length", JIT_G(max_trace_length));
#endif

Expand Down
6 changes: 5 additions & 1 deletion ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,11 @@ char *sockets_strerror(int error) /* {{{ */

#ifndef PHP_WIN32
if (error < -10000) {
error = -error - 10000;
if (error == INT_MIN) {
error = 2147473648;
} else {
error = -error - 10000;
}

#ifdef HAVE_HSTRERROR
buf = hstrerror(error);
Expand Down
Loading
Loading