From 25d761623cd9eb2ed1c1e5fdefa122b89d428caf Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 7 Sep 2024 01:45:26 +0200 Subject: [PATCH 01/24] Make internal run_time_cache a persistent allocation (#15040) We also add zend_map_ptr_static, so that we do not incur the overhead of constantly recreating the internal run_time_cache pointers on each request. This mechanism might be extended for mutable_data of internal classes too. --- Zend/zend.c | 55 +++++++++++++++++++++++++++++------ Zend/zend_API.c | 6 +++- Zend/zend_enum.c | 6 +++- Zend/zend_extensions.c | 19 ++++++++---- Zend/zend_extensions.h | 1 + Zend/zend_globals.h | 3 ++ Zend/zend_map_ptr.h | 13 +++++++-- ext/ffi/ffi.c | 5 ++++ ext/opcache/jit/zend_jit_ir.c | 6 +++- ext/xmlreader/php_xmlreader.c | 4 +++ main/main.c | 3 ++ 11 files changed, 101 insertions(+), 20 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 9f6e709efbecf..2d3aa4f8e3300 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -735,14 +735,16 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{ compiler_globals->map_ptr_base = ZEND_MAP_PTR_BIASED_BASE(NULL); compiler_globals->map_ptr_size = 0; compiler_globals->map_ptr_last = global_map_ptr_last; - if (compiler_globals->map_ptr_last) { + compiler_globals->internal_run_time_cache = NULL; + if (compiler_globals->map_ptr_last || zend_map_ptr_static_size) { /* Allocate map_ptr table */ compiler_globals->map_ptr_size = ZEND_MM_ALIGNED_SIZE_EX(compiler_globals->map_ptr_last, 4096); - void *base = pemalloc(compiler_globals->map_ptr_size * sizeof(void*), 1); + void *base = pemalloc((zend_map_ptr_static_size + compiler_globals->map_ptr_size) * sizeof(void*), 1); compiler_globals->map_ptr_real_base = base; compiler_globals->map_ptr_base = ZEND_MAP_PTR_BIASED_BASE(base); - memset(base, 0, compiler_globals->map_ptr_last * sizeof(void*)); + memset(base, 0, (zend_map_ptr_static_size + compiler_globals->map_ptr_last) * sizeof(void*)); } + zend_init_internal_run_time_cache(); } /* }}} */ @@ -785,6 +787,10 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) /* {{ compiler_globals->map_ptr_base = ZEND_MAP_PTR_BIASED_BASE(NULL); compiler_globals->map_ptr_size = 0; } + if (compiler_globals->internal_run_time_cache) { + pefree(compiler_globals->internal_run_time_cache, 1); + compiler_globals->internal_run_time_cache = NULL; + } } /* }}} */ @@ -1115,6 +1121,10 @@ zend_result zend_post_startup(void) /* {{{ */ } compiler_globals->map_ptr_real_base = NULL; compiler_globals->map_ptr_base = ZEND_MAP_PTR_BIASED_BASE(NULL); + if (compiler_globals->internal_run_time_cache) { + pefree(compiler_globals->internal_run_time_cache, 1); + } + compiler_globals->internal_run_time_cache = NULL; if ((script_encoding_list = (zend_encoding **)compiler_globals->script_encoding_list)) { compiler_globals_ctor(compiler_globals); compiler_globals->script_encoding_list = (const zend_encoding **)script_encoding_list; @@ -1198,6 +1208,9 @@ void zend_shutdown(void) /* {{{ */ CG(script_encoding_list_size) = 0; } #endif + zend_map_ptr_static_last = 0; + zend_map_ptr_static_size = 0; + zend_destroy_rsrc_list_dtors(); zend_unload_modules(); @@ -1297,9 +1310,9 @@ ZEND_API void zend_activate(void) /* {{{ */ init_executor(); startup_scanner(); if (CG(map_ptr_last)) { - memset(CG(map_ptr_real_base), 0, CG(map_ptr_last) * sizeof(void*)); + memset((void **)CG(map_ptr_real_base) + zend_map_ptr_static_size, 0, CG(map_ptr_last) * sizeof(void*)); } - zend_init_internal_run_time_cache(); + zend_reset_internal_run_time_cache(); zend_observer_activate(); } /* }}} */ @@ -1984,6 +1997,9 @@ void free_estring(char **str_p) /* {{{ */ } /* }}} */ +ZEND_API size_t zend_map_ptr_static_size; +ZEND_API size_t zend_map_ptr_static_last; + ZEND_API void zend_map_ptr_reset(void) { CG(map_ptr_last) = global_map_ptr_last; @@ -1996,15 +2012,36 @@ ZEND_API void *zend_map_ptr_new(void) if (CG(map_ptr_last) >= CG(map_ptr_size)) { /* Grow map_ptr table */ CG(map_ptr_size) = ZEND_MM_ALIGNED_SIZE_EX(CG(map_ptr_last) + 1, 4096); - CG(map_ptr_real_base) = perealloc(CG(map_ptr_real_base), CG(map_ptr_size) * sizeof(void*), 1); + CG(map_ptr_real_base) = perealloc(CG(map_ptr_real_base), (zend_map_ptr_static_size + CG(map_ptr_size)) * sizeof(void*), 1); CG(map_ptr_base) = ZEND_MAP_PTR_BIASED_BASE(CG(map_ptr_real_base)); } - ptr = (void**)CG(map_ptr_real_base) + CG(map_ptr_last); + ptr = (void**)CG(map_ptr_real_base) + zend_map_ptr_static_size + CG(map_ptr_last); *ptr = NULL; CG(map_ptr_last)++; return ZEND_MAP_PTR_PTR2OFFSET(ptr); } +ZEND_API void *zend_map_ptr_new_static(void) +{ + void **ptr; + + if (zend_map_ptr_static_last >= zend_map_ptr_static_size) { + zend_map_ptr_static_size += 4096; + /* Grow map_ptr table */ + void *new_base = pemalloc((zend_map_ptr_static_size + CG(map_ptr_size)) * sizeof(void*), 1); + if (CG(map_ptr_real_base)) { + memcpy((void **)new_base + 4096, CG(map_ptr_real_base), (CG(map_ptr_last) + zend_map_ptr_static_size - 4096) * sizeof(void *)); + pefree(CG(map_ptr_real_base), 1); + } + CG(map_ptr_real_base) = new_base; + CG(map_ptr_base) = ZEND_MAP_PTR_BIASED_BASE(new_base); + } + ptr = (void**)CG(map_ptr_real_base) + (zend_map_ptr_static_last & 4095); + *ptr = NULL; + zend_map_ptr_static_last++; + return ZEND_MAP_PTR_PTR2OFFSET(ptr); +} + ZEND_API void zend_map_ptr_extend(size_t last) { if (last > CG(map_ptr_last)) { @@ -2013,10 +2050,10 @@ ZEND_API void zend_map_ptr_extend(size_t last) if (last >= CG(map_ptr_size)) { /* Grow map_ptr table */ CG(map_ptr_size) = ZEND_MM_ALIGNED_SIZE_EX(last, 4096); - CG(map_ptr_real_base) = perealloc(CG(map_ptr_real_base), CG(map_ptr_size) * sizeof(void*), 1); + CG(map_ptr_real_base) = perealloc(CG(map_ptr_real_base), (zend_map_ptr_static_size + CG(map_ptr_size)) * sizeof(void*), 1); CG(map_ptr_base) = ZEND_MAP_PTR_BIASED_BASE(CG(map_ptr_real_base)); } - ptr = (void**)CG(map_ptr_real_base) + CG(map_ptr_last); + ptr = (void**)CG(map_ptr_real_base) + zend_map_ptr_static_size + CG(map_ptr_last); memset(ptr, 0, (last - CG(map_ptr_last)) * sizeof(void*)); CG(map_ptr_last) = last; } diff --git a/Zend/zend_API.c b/Zend/zend_API.c index b4f13bedecc56..2319862488ca6 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2958,7 +2958,11 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend if (EG(active)) { // at run-time: this ought to only happen if registered with dl() or somehow temporarily at runtime ZEND_MAP_PTR_INIT(internal_function->run_time_cache, zend_arena_calloc(&CG(arena), 1, zend_internal_run_time_cache_reserved_size())); } else { - ZEND_MAP_PTR_NEW(internal_function->run_time_cache); +#if ZTS + ZEND_MAP_PTR_NEW_STATIC(internal_function->run_time_cache); +#else + ZEND_MAP_PTR_INIT(internal_function->run_time_cache, NULL); +#endif } if (ptr->flags) { if (!(ptr->flags & ZEND_ACC_PPP_MASK)) { diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index 309d7da1cf7aa..e6731aed40d2b 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -421,7 +421,11 @@ static void zend_enum_register_func(zend_class_entry *ce, zend_known_string_id n if (EG(active)) { // at run-time ZEND_MAP_PTR_INIT(zif->run_time_cache, zend_arena_calloc(&CG(arena), 1, zend_internal_run_time_cache_reserved_size())); } else { - ZEND_MAP_PTR_NEW(zif->run_time_cache); +#if ZTS + ZEND_MAP_PTR_NEW_STATIC(zif->run_time_cache); +#else + ZEND_MAP_PTR_INIT(zif->run_time_cache, NULL); +#endif } if (!zend_hash_add_ptr(&ce->function_table, name, zif)) { diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c index c3719219655c2..fecea4fa0b5ea 100644 --- a/Zend/zend_extensions.c +++ b/Zend/zend_extensions.c @@ -331,19 +331,22 @@ ZEND_API void zend_init_internal_run_time_cache(void) { functions += zend_hash_num_elements(&ce->function_table); } ZEND_HASH_FOREACH_END(); - char *ptr = zend_arena_calloc(&CG(arena), functions, rt_size); + size_t alloc_size = functions * rt_size; + char *ptr = pemalloc(alloc_size, 1); + + CG(internal_run_time_cache) = ptr; + CG(internal_run_time_cache_size) = alloc_size; + zend_internal_function *zif; ZEND_HASH_MAP_FOREACH_PTR(CG(function_table), zif) { - if (!ZEND_USER_CODE(zif->type) && ZEND_MAP_PTR_GET(zif->run_time_cache) == NULL) - { + if (!ZEND_USER_CODE(zif->type) && ZEND_MAP_PTR_GET(zif->run_time_cache) == NULL) { ZEND_MAP_PTR_SET(zif->run_time_cache, (void *)ptr); ptr += rt_size; } } ZEND_HASH_FOREACH_END(); ZEND_HASH_MAP_FOREACH_PTR(CG(class_table), ce) { ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, zif) { - if (!ZEND_USER_CODE(zif->type) && ZEND_MAP_PTR_GET(zif->run_time_cache) == NULL) - { + if (!ZEND_USER_CODE(zif->type) && ZEND_MAP_PTR_GET(zif->run_time_cache) == NULL) { ZEND_MAP_PTR_SET(zif->run_time_cache, (void *)ptr); ptr += rt_size; } @@ -352,6 +355,12 @@ ZEND_API void zend_init_internal_run_time_cache(void) { } } +ZEND_API void zend_reset_internal_run_time_cache(void) { + if (CG(internal_run_time_cache)) { + memset(CG(internal_run_time_cache), 0, CG(internal_run_time_cache_size)); + } +} + ZEND_API zend_extension *zend_get_extension(const char *extension_name) { zend_llist_element *element; diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h index 908c90e7d0485..15aaa14f91513 100644 --- a/Zend/zend_extensions.h +++ b/Zend/zend_extensions.h @@ -149,6 +149,7 @@ void zend_shutdown_extensions(void); ZEND_API size_t zend_internal_run_time_cache_reserved_size(void); ZEND_API void zend_init_internal_run_time_cache(void); +ZEND_API void zend_reset_internal_run_time_cache(void); BEGIN_EXTERN_C() ZEND_API zend_result zend_load_extension(const char *path); diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 539793c8325a6..62a97d753634a 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -154,6 +154,9 @@ struct _zend_compiler_globals { uint32_t rtd_key_counter; + void *internal_run_time_cache; + uint32_t internal_run_time_cache_size; + zend_stack short_circuiting_opnums; #ifdef ZTS uint32_t copied_functions_count; diff --git a/Zend/zend_map_ptr.h b/Zend/zend_map_ptr.h index 7a0d853dbd166..ebcda89411d0e 100644 --- a/Zend/zend_map_ptr.h +++ b/Zend/zend_map_ptr.h @@ -42,6 +42,9 @@ typedef struct _zend_string zend_string; #define ZEND_MAP_PTR_NEW(ptr) do { \ ZEND_MAP_PTR(ptr) = zend_map_ptr_new(); \ } while (0) +#define ZEND_MAP_PTR_NEW_STATIC(ptr) do { \ + ZEND_MAP_PTR(ptr) = zend_map_ptr_new_static(); \ + } while (0) #if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR_OR_OFFSET # define ZEND_MAP_PTR_NEW_OFFSET() \ @@ -53,7 +56,7 @@ typedef struct _zend_string zend_string; ZEND_MAP_PTR_GET_IMM(ptr) : \ ((void*)(ZEND_MAP_PTR(ptr))))) # define ZEND_MAP_PTR_GET_IMM(ptr) \ - (*ZEND_MAP_PTR_OFFSET2PTR((uintptr_t)ZEND_MAP_PTR(ptr))) + (*ZEND_MAP_PTR_OFFSET2PTR((intptr_t)ZEND_MAP_PTR(ptr))) # define ZEND_MAP_PTR_SET(ptr, val) do { \ if (ZEND_MAP_PTR_IS_OFFSET(ptr)) { \ ZEND_MAP_PTR_SET_IMM(ptr, val); \ @@ -62,11 +65,11 @@ typedef struct _zend_string zend_string; } \ } while (0) # define ZEND_MAP_PTR_SET_IMM(ptr, val) do { \ - void **__p = ZEND_MAP_PTR_OFFSET2PTR((uintptr_t)ZEND_MAP_PTR(ptr)); \ + void **__p = ZEND_MAP_PTR_OFFSET2PTR((intptr_t)ZEND_MAP_PTR(ptr)); \ *__p = (val); \ } while (0) # define ZEND_MAP_PTR_BIASED_BASE(real_base) \ - ((void*)(((uintptr_t)(real_base)) - 1)) + ((void*)(((uintptr_t)(real_base)) + zend_map_ptr_static_size * sizeof(void *) - 1)) #else # error "Unknown ZEND_MAP_PTR_KIND" #endif @@ -75,9 +78,13 @@ BEGIN_EXTERN_C() ZEND_API void zend_map_ptr_reset(void); ZEND_API void *zend_map_ptr_new(void); +ZEND_API void *zend_map_ptr_new_static(void); ZEND_API void zend_map_ptr_extend(size_t last); ZEND_API void zend_alloc_ce_cache(zend_string *type_name); +ZEND_API extern size_t zend_map_ptr_static_last; +ZEND_API extern size_t zend_map_ptr_static_size; + END_EXTERN_C() #endif /* ZEND_MAP_PTR_H */ diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 6d9216b6f7f3f..4e5dfc632c9ba 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -5393,6 +5393,11 @@ static zend_result ffi_fixup_temporaries(void) { ++zend_ffi_cast_fn.T; ++zend_ffi_type_fn.T; } +#if !ZTS + ZEND_MAP_PTR(zend_ffi_new_fn.run_time_cache) = ZEND_MAP_PTR(((zend_internal_function *)zend_hash_str_find_ptr(&zend_ffi_ce->function_table, "new", sizeof("new")-1))->run_time_cache); + ZEND_MAP_PTR(zend_ffi_cast_fn.run_time_cache) = ZEND_MAP_PTR(((zend_internal_function *)zend_hash_str_find_ptr(&zend_ffi_ce->function_table, "cast", sizeof("cast")-1))->run_time_cache); + ZEND_MAP_PTR(zend_ffi_type_fn.run_time_cache) = ZEND_MAP_PTR(((zend_internal_function *)zend_hash_str_find_ptr(&zend_ffi_ce->function_table, "type", sizeof("type")-1))->run_time_cache); +#endif if (prev_zend_post_startup_cb) { return prev_zend_post_startup_cb(); } diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 0f79b83832e6a..848c3308b3a51 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -4534,8 +4534,12 @@ static struct jit_observer_fcall_is_unobserved_data jit_observer_fcall_is_unobse if (func && (func->common.fn_flags & ZEND_ACC_CLOSURE) == 0 && ZEND_MAP_PTR_IS_OFFSET(func->common.run_time_cache)) { // JIT: ZEND_MAP_PTR_GET_IMM(func->common.runtime_cache) run_time_cache = ir_LOAD_A(ir_ADD_OFFSET(ir_LOAD_A(jit_CG(map_ptr_base)), (uintptr_t)ZEND_MAP_PTR(func->common.run_time_cache))); +#if !ZTS + } else if (func && rx == IS_UNUSED) { // happens for internal functions only + ZEND_ASSERT(!ZEND_USER_CODE(func->type)); + run_time_cache = ir_LOAD_A(ir_ADD_OFFSET(ir_CONST_ADDR(func), offsetof(zend_op_array, run_time_cache__ptr))); +#endif } else { - ZEND_ASSERT(rx != IR_UNUSED); // Closures may be duplicated and have a different runtime cache. Use the regular run_time_cache access pattern for these if (func && ZEND_USER_CODE(func->type)) { // not a closure and definitely not an internal function run_time_cache = ir_LOAD_A(jit_CALL(rx, run_time_cache)); diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c index 528fd8b351c61..e8f63bade5bef 100644 --- a/ext/xmlreader/php_xmlreader.c +++ b/ext/xmlreader/php_xmlreader.c @@ -1276,6 +1276,10 @@ static zend_result xmlreader_fixup_temporaries(void) { ++xmlreader_open_fn.T; ++xmlreader_xml_fn.T; } +#if !ZTS + ZEND_MAP_PTR(xmlreader_open_fn.run_time_cache) = ZEND_MAP_PTR(((zend_internal_function *)zend_hash_str_find_ptr(&xmlreader_class_entry->function_table, "open", sizeof("open")-1))->run_time_cache); + ZEND_MAP_PTR(xmlreader_xml_fn.run_time_cache) = ZEND_MAP_PTR(((zend_internal_function *)zend_hash_str_find_ptr(&xmlreader_class_entry->function_table, "xml", sizeof("xml")-1))->run_time_cache); +#endif if (prev_zend_post_startup_cb) { return prev_zend_post_startup_cb(); } diff --git a/main/main.c b/main/main.c index 26d38b83e1644..d31de566f48b8 100644 --- a/main/main.c +++ b/main/main.c @@ -2316,6 +2316,9 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi /* freeze the list of observer fcall_init handlers */ zend_observer_post_startup(); + /* freeze the list of persistent internal functions */ + zend_init_internal_run_time_cache(); + /* Extensions that add engine hooks after this point do so at their own peril */ zend_finalize_system_id(); From 56400f709b86318ec209bc404536afc96fc39e9e Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 7 Sep 2024 05:53:00 +0200 Subject: [PATCH 02/24] Autotools: s/M4 macros/Autoconf macros (#15778) M4 macros would mean macros for M4 language like m4_normalize() and similar. Macros defined with AC_DEFUN are better called simply Auotoconf macros. [skip ci] --- UPGRADING.INTERNALS | 52 ++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 85a45a866c711..ea0be872843a3 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -140,15 +140,16 @@ PHP 8.4 INTERNALS UPGRADE NOTES - COOKIE_IO_FUNCTIONS_T symbol has been removed (use cookie_io_functions_t). - HAVE_SOCKADDR_UN_SUN_LEN symbol renamed to HAVE_STRUCT_SOCKADDR_UN_SUN_LEN. - HAVE_UTSNAME_DOMAINNAME symbol renamed to HAVE_STRUCT_UTSNAME_DOMAINNAME. - - PHP_CHECK_IN_ADDR_T M4 macro and 'in_addr_t' fallback definition to 'u_int' - removed (use AC_CHECK_TYPES Autoconf macro instead). + - PHP_CHECK_IN_ADDR_T Autoconf macro and 'in_addr_t' fallback definition to + 'u_int' removed (use AC_CHECK_TYPES Autoconf macro instead). - HAVE_ODBC2 symbol has been removed in ext/odbc. - Removed linking with obsolete dnet_stub library in ext/pdo_dblib. - Removed checking and linking with obsolete libbind for some functions. - Symbol HAVE_JSON has been removed (ext/json is always available since PHP 8.0). - Symbol DARWIN has been removed (use __APPLE__ to target Darwin systems). - - Symbol MISSING_FCLOSE_DECL and M4 macro PHP_MISSING_FCLOSE_DECL removed. + - Symbol MISSING_FCLOSE_DECL and Autoconf macro PHP_MISSING_FCLOSE_DECL were + removed. - Symbol HAVE_BSD_ICONV has been removed. - Symbol ZEND_FIBER_ASM has been removed. - Symbols HAVE_DLOPEN and HAVE_DLSYM have been removed. @@ -164,39 +165,42 @@ PHP 8.4 INTERNALS UPGRADE NOTES - Symbols PHP_HAVE_AVX512_SUPPORTS and PHP_HAVE_AVX512_VBMI_SUPPORTS are now either defined to 1 or undefined. - Symbol HAVE_LIBCRYPT has been removed. - - M4 macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and config.h). - - M4 macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH). - - M4 macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES). - - M4 macro PHP_SOCKADDR_CHECKS has been removed (use AC_CHECK_TYPES and + - Autoconf macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and + config.h). + - Autoconf macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH). + - Autoconf macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES). + - Autoconf macro PHP_SOCKADDR_CHECKS has been removed (use AC_CHECK_TYPES and AC_CHECK_MEMBERS). - - M4 macro PHP_CHECK_GCC_ARG has been removed since PHP 8.0 (use + - Autoconf macro PHP_CHECK_GCC_ARG has been removed since PHP 8.0 (use AX_CHECK_COMPILE_FLAG). - - M4 macro PHP_PROG_RE2C got a new 2nd argument to define common default re2c - command-line options substituted to the Makefile RE2C_FLAGS variable. - - M4 macros PHP_CHECK_BUILTIN_* have been removed in favor of + - Autoconf macro PHP_PROG_RE2C got a new 2nd argument to define common + default re2c command-line options substituted to the Makefile RE2C_FLAGS + variable. + - Autoconf macros PHP_CHECK_BUILTIN_* have been removed in favor of PHP_CHECK_BUILTIN and all PHP_HAVE_BUILTIN_* symbols changed to be either undefined or defined to 1 whether compiler supports the builtin. - Added php-config --lib-dir and --lib-embed options for PHP embed SAPI. - PDO extensions in php-src don't have the include flag -I$pdo_cv_inc_path directory anymore. - - M4 macro PHP_SETUP_OPENSSL doesn't accept the 3rd argument anymore. - - M4 macro PHP_EVAL_LIBLINE got a new 3rd argument to override the ext_shared - checks. - - M4 macro PHP_SETUP_LIBXML doesn't define the redundant HAVE_LIBXML symbol - anymore and requires at least libxml2 2.9.4. - - M4 macro PHP_SETUP_ICONV doesn't define the HAVE_ICONV symbol anymore. - - M4 macro PHP_OUTPUT is obsolete (use AC_CONFIG_FILES). - - M4 macro PHP_PROG_SETUP now accepts an argument to set the minimum required - PHP version during the build. - - M4 macro PHP_INSTALL_HEADERS arguments can now be also + - Autoconf macro PHP_SETUP_OPENSSL doesn't accept the 3rd argument anymore. + - Autoconf macro PHP_EVAL_LIBLINE got a new 3rd argument to override the + ext_shared checks. + - Autoconf macro PHP_SETUP_LIBXML doesn't define the redundant HAVE_LIBXML + symbol anymore and requires at least libxml2 2.9.4. + - Autoconf macro PHP_SETUP_ICONV doesn't define the HAVE_ICONV symbol + anymore. + - Autoconf macro PHP_OUTPUT is obsolete (use AC_CONFIG_FILES). + - Autoconf macro PHP_PROG_SETUP now accepts an argument to set the minimum + required PHP version during the build. + - Autoconf macro PHP_INSTALL_HEADERS arguments can now be also blank-or-newline-separated lists instead of only separated with whitespace or backslash-then-newline. - - M4 macro PHP_ADD_BUILD_DIR now also accepts 1st argument as a + - Autoconf macro PHP_ADD_BUILD_DIR now also accepts 1st argument as a blank-or-newline-separated separated list. - - M4 macros PHP_NEW_EXTENSION, PHP_ADD_SOURCES, PHP_ADD_SOURCES_X, + - Autoconf macros PHP_NEW_EXTENSION, PHP_ADD_SOURCES, PHP_ADD_SOURCES_X, PHP_SELECT_SAPI now have the source files and flags arguments normalized so the list of items can be passed as a blank-or-newline-separated list. - - TSRM/tsrm.m4 file and its TSRM_CHECK_PTHREADS M4 macro have been removed. + - TSRM/tsrm.m4 file and its TSRM_CHECK_PTHREADS macro have been removed. - Added pkg-config support to find libpq for the pdo_pgsql and pgsql extensions. The libpq paths can be customized with the PGSQL_CFLAGS and PGSQL_LIBS environment variables. When a directory argument is provided to From 047f0c9657921d2b7b2829a90812e63a3fd49d7e Mon Sep 17 00:00:00 2001 From: DanielEScherzer Date: Fri, 6 Sep 2024 22:37:05 -0700 Subject: [PATCH 03/24] userland_declaration_error_class_const.phpt: fix test name (#15784) Unlike the `userland_declaration_error_const.phpt` test, the point of this test is to demonstrate using a class constant as the default parameter. See also the corresponding internal_declaration_* tests. [skip ci] --- .../userland_declaration_error_class_const.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/tests/parameter_default_values/userland_declaration_error_class_const.phpt b/Zend/tests/parameter_default_values/userland_declaration_error_class_const.phpt index 40648c80b229e..7011059e276ba 100644 --- a/Zend/tests/parameter_default_values/userland_declaration_error_class_const.phpt +++ b/Zend/tests/parameter_default_values/userland_declaration_error_class_const.phpt @@ -1,5 +1,5 @@ --TEST-- -The default value is a constant in the parent class method's signature. +The default value is a class constant in the parent class method's signature. --FILE-- Date: Sat, 7 Sep 2024 00:22:10 -0700 Subject: [PATCH 04/24] [skip ci] docs: fix constant syntax in stubs.rst (#15785) Constants are declared with `=` not `:` --- docs/source/miscellaneous/stubs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/miscellaneous/stubs.rst b/docs/source/miscellaneous/stubs.rst index 5a3f5b02217b0..481c26ebc4a0f 100644 --- a/docs/source/miscellaneous/stubs.rst +++ b/docs/source/miscellaneous/stubs.rst @@ -31,7 +31,7 @@ using namespace blocks: /** @var string */ const ANIMAL = "Elephant"; /** @var float */ - const WEIGHT_TON: 6.8; + const WEIGHT_TON = 6.8; class Atmopshere { public function calculateBar(): float {} From 5ea6b044cd5a88291caa62cff740e5d1030a45e7 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 7 Sep 2024 09:46:06 +0200 Subject: [PATCH 05/24] Autotools: Fix gd extension -I flag for bundled libgd (#15786) The ext_srcdir variable is at time of writing set only after calling the PHP_NEW_EXTENSION. Other extensions also use @ext_srcdir@ template placeholder for these cases. This fixes wrongly set include flag even though build also works without libgd include flag. --- ext/gd/config.m4 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/gd/config.m4 b/ext/gd/config.m4 index d1d727b130c48..c58310be57302 100644 --- a/ext/gd/config.m4 +++ b/ext/gd/config.m4 @@ -279,8 +279,10 @@ dnl Various checks for GD features PHP_GD_FREETYPE2 PHP_GD_JISX0208 - GD_CFLAGS="-Wno-strict-prototypes -I$ext_srcdir/libgd $GD_CFLAGS" - PHP_NEW_EXTENSION([gd], [gd.c $extra_sources], [$ext_shared],, [$GD_CFLAGS]) + PHP_NEW_EXTENSION([gd], + [gd.c $extra_sources], + [$ext_shared],, + [-Wno-strict-prototypes -I@ext_srcdir@/libgd]) PHP_ADD_BUILD_DIR([$ext_builddir/libgd]) PHP_INSTALL_HEADERS([ext/gd], [php_gd.h libgd/]) From de48b90d61032d71fb263acbb1a767bae19f3e50 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 7 Sep 2024 11:03:32 +0200 Subject: [PATCH 06/24] Convert CRLF line endings to LF (#15767) This patch simplifies line endings tracked in the Git repository and syncs them to the LF style instead of the CRLF. Newline characters: - LF (\n) (*nix and Mac) - CRLF (\r\n) (Windows) - CR (\r) (old Mac, obsolete) To see which line endings are in the index and in the working copy the following command can be used: `git ls-files --eol` Git also provides `.gitattributes` file to specify files that need specific line endings in the working directory on all platforms (either CRLF or LF): ``` file-with-crlf text eol=crlf ``` Changed files shouldn't cause issues on modern Windows platforms because also Git can do output conversion if core.autocrlf=true is set on Windows and use CRLF newlines in all files in the working tree. Unless CRLF files are tracked specifically, Git by default tracks all files in the index using LF newlines. --- Zend/asm/jump_arm64_aapcs_pe_armasm.asm | 264 ++++++++++++------------ Zend/asm/make_arm64_aapcs_pe_armasm.asm | 214 +++++++++---------- 2 files changed, 239 insertions(+), 239 deletions(-) diff --git a/Zend/asm/jump_arm64_aapcs_pe_armasm.asm b/Zend/asm/jump_arm64_aapcs_pe_armasm.asm index d2e7d221415a3..3100243d68dee 100644 --- a/Zend/asm/jump_arm64_aapcs_pe_armasm.asm +++ b/Zend/asm/jump_arm64_aapcs_pe_armasm.asm @@ -1,133 +1,133 @@ -; Copyright Edward Nevill + Oliver Kowalke 2015 -; Distributed under the Boost Software License, Version 1.0. -; (See accompanying file LICENSE_1_0.txt or copy at -; http://www.boost.org/LICENSE_1_0.txt) - -;******************************************************* -;* * -;* ------------------------------------------------- * -;* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * -;* ------------------------------------------------- * -;* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * -;* ------------------------------------------------- * -;* | d8 | d9 | d10 | d11 | * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * -;* ------------------------------------------------- * -;* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * -;* ------------------------------------------------- * -;* | d12 | d13 | d14 | d15 | * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * -;* ------------------------------------------------- * -;* | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * -;* ------------------------------------------------- * -;* | x19 | x20 | x21 | x22 | * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * -;* ------------------------------------------------- * -;* | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * -;* ------------------------------------------------- * -;* | x23 | x24 | x25 | x26 | * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * -;* ------------------------------------------------- * -;* | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * -;* ------------------------------------------------- * -;* | x27 | x28 | FP | LR | * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * -;* ------------------------------------------------- * -;* | 0xa0| 0xa4| 0xa8| 0xac| 0xb0| 0xb4| 0xb8| 0xbc| * -;* ------------------------------------------------- * -;* | fiber data| base | limit | dealloc | * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 48 | 49 | 50 | 51 | | | * -;* ------------------------------------------------- * -;* | 0xc0| 0xc4| 0xc8| 0xcc| | | * -;* ------------------------------------------------- * -;* | PC | align | | | * -;* ------------------------------------------------- * -;* * -;******************************************************* - - AREA |.text|, CODE, READONLY, ALIGN=4, CODEALIGN - EXPORT jump_fcontext - -jump_fcontext proc - ; prepare stack for GP + FPU - sub sp, sp, #0xd0 - - ; save d8 - d15 - stp d8, d9, [sp, #0x00] - stp d10, d11, [sp, #0x10] - stp d12, d13, [sp, #0x20] - stp d14, d15, [sp, #0x30] - - ; save x19-x30 - stp x19, x20, [sp, #0x40] - stp x21, x22, [sp, #0x50] - stp x23, x24, [sp, #0x60] - stp x25, x26, [sp, #0x70] - stp x27, x28, [sp, #0x80] - stp x29, x30, [sp, #0x90] - - ; save LR as PC - str x30, [sp, #0xc0] - - ; save current stack base and limit - ldp x5, x6, [x18, #0x08] ; TeStackBase and TeStackLimit at ksarm64.h - stp x5, x6, [sp, #0xa0] - ; save current fiber data and deallocation stack - ldr x5, [x18, #0x1478] ; TeDeallocationStack at ksarm64.h - ldr x6, [x18, #0x20] ; TeFiberData at ksarm64.h - stp x5, x6, [sp, #0xb0] - - ; store RSP (pointing to context-data) in X0 - mov x4, sp - - ; restore RSP (pointing to context-data) from X1 - mov sp, x0 - - ; restore stack base and limit - ldp x5, x6, [sp, #0xa0] - stp x5, x6, [x18, #0x08] ; TeStackBase and TeStackLimit at ksarm64.h - ; restore fiber data and deallocation stack - ldp x5, x6, [sp, #0xb0] - str x5, [x18, #0x1478] ; TeDeallocationStack at ksarm64.h - str x6, [x18, #0x20] ; TeFiberData at ksarm64.h - - ; load d8 - d15 - ldp d8, d9, [sp, #0x00] - ldp d10, d11, [sp, #0x10] - ldp d12, d13, [sp, #0x20] - ldp d14, d15, [sp, #0x30] - - ; load x19-x30 - ldp x19, x20, [sp, #0x40] - ldp x21, x22, [sp, #0x50] - ldp x23, x24, [sp, #0x60] - ldp x25, x26, [sp, #0x70] - ldp x27, x28, [sp, #0x80] - ldp x29, x30, [sp, #0x90] - - ; return transfer_t from jump - ; pass transfer_t as first arg in context function - ; X0 == FCTX, X1 == DATA - mov x0, x4 - - ; load pc - ldr x4, [sp, #0xc0] - - ; restore stack from GP + FPU - add sp, sp, #0xd0 - - ret x4 - ENDP +; Copyright Edward Nevill + Oliver Kowalke 2015 +; Distributed under the Boost Software License, Version 1.0. +; (See accompanying file LICENSE_1_0.txt or copy at +; http://www.boost.org/LICENSE_1_0.txt) + +;******************************************************* +;* * +;* ------------------------------------------------- * +;* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * +;* ------------------------------------------------- * +;* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * +;* ------------------------------------------------- * +;* | d8 | d9 | d10 | d11 | * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * +;* ------------------------------------------------- * +;* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * +;* ------------------------------------------------- * +;* | d12 | d13 | d14 | d15 | * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * +;* ------------------------------------------------- * +;* | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * +;* ------------------------------------------------- * +;* | x19 | x20 | x21 | x22 | * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * +;* ------------------------------------------------- * +;* | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * +;* ------------------------------------------------- * +;* | x23 | x24 | x25 | x26 | * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * +;* ------------------------------------------------- * +;* | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * +;* ------------------------------------------------- * +;* | x27 | x28 | FP | LR | * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * +;* ------------------------------------------------- * +;* | 0xa0| 0xa4| 0xa8| 0xac| 0xb0| 0xb4| 0xb8| 0xbc| * +;* ------------------------------------------------- * +;* | fiber data| base | limit | dealloc | * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 48 | 49 | 50 | 51 | | | * +;* ------------------------------------------------- * +;* | 0xc0| 0xc4| 0xc8| 0xcc| | | * +;* ------------------------------------------------- * +;* | PC | align | | | * +;* ------------------------------------------------- * +;* * +;******************************************************* + + AREA |.text|, CODE, READONLY, ALIGN=4, CODEALIGN + EXPORT jump_fcontext + +jump_fcontext proc + ; prepare stack for GP + FPU + sub sp, sp, #0xd0 + + ; save d8 - d15 + stp d8, d9, [sp, #0x00] + stp d10, d11, [sp, #0x10] + stp d12, d13, [sp, #0x20] + stp d14, d15, [sp, #0x30] + + ; save x19-x30 + stp x19, x20, [sp, #0x40] + stp x21, x22, [sp, #0x50] + stp x23, x24, [sp, #0x60] + stp x25, x26, [sp, #0x70] + stp x27, x28, [sp, #0x80] + stp x29, x30, [sp, #0x90] + + ; save LR as PC + str x30, [sp, #0xc0] + + ; save current stack base and limit + ldp x5, x6, [x18, #0x08] ; TeStackBase and TeStackLimit at ksarm64.h + stp x5, x6, [sp, #0xa0] + ; save current fiber data and deallocation stack + ldr x5, [x18, #0x1478] ; TeDeallocationStack at ksarm64.h + ldr x6, [x18, #0x20] ; TeFiberData at ksarm64.h + stp x5, x6, [sp, #0xb0] + + ; store RSP (pointing to context-data) in X0 + mov x4, sp + + ; restore RSP (pointing to context-data) from X1 + mov sp, x0 + + ; restore stack base and limit + ldp x5, x6, [sp, #0xa0] + stp x5, x6, [x18, #0x08] ; TeStackBase and TeStackLimit at ksarm64.h + ; restore fiber data and deallocation stack + ldp x5, x6, [sp, #0xb0] + str x5, [x18, #0x1478] ; TeDeallocationStack at ksarm64.h + str x6, [x18, #0x20] ; TeFiberData at ksarm64.h + + ; load d8 - d15 + ldp d8, d9, [sp, #0x00] + ldp d10, d11, [sp, #0x10] + ldp d12, d13, [sp, #0x20] + ldp d14, d15, [sp, #0x30] + + ; load x19-x30 + ldp x19, x20, [sp, #0x40] + ldp x21, x22, [sp, #0x50] + ldp x23, x24, [sp, #0x60] + ldp x25, x26, [sp, #0x70] + ldp x27, x28, [sp, #0x80] + ldp x29, x30, [sp, #0x90] + + ; return transfer_t from jump + ; pass transfer_t as first arg in context function + ; X0 == FCTX, X1 == DATA + mov x0, x4 + + ; load pc + ldr x4, [sp, #0xc0] + + ; restore stack from GP + FPU + add sp, sp, #0xd0 + + ret x4 + ENDP END \ No newline at end of file diff --git a/Zend/asm/make_arm64_aapcs_pe_armasm.asm b/Zend/asm/make_arm64_aapcs_pe_armasm.asm index 16fcdc7d8f7e8..50f9b69876bed 100644 --- a/Zend/asm/make_arm64_aapcs_pe_armasm.asm +++ b/Zend/asm/make_arm64_aapcs_pe_armasm.asm @@ -1,107 +1,107 @@ -; Copyright Edward Nevill + Oliver Kowalke 2015 -; Distributed under the Boost Software License, Version 1.0. -; (See accompanying file LICENSE_1_0.txt or copy at -; http://www.boost.org/LICENSE_1_0.txt) - -;******************************************************* -;* * -;* ------------------------------------------------- * -;* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * -;* ------------------------------------------------- * -;* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * -;* ------------------------------------------------- * -;* | d8 | d9 | d10 | d11 | * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * -;* ------------------------------------------------- * -;* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * -;* ------------------------------------------------- * -;* | d12 | d13 | d14 | d15 | * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * -;* ------------------------------------------------- * -;* | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * -;* ------------------------------------------------- * -;* | x19 | x20 | x21 | x22 | * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * -;* ------------------------------------------------- * -;* | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * -;* ------------------------------------------------- * -;* | x23 | x24 | x25 | x26 | * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * -;* ------------------------------------------------- * -;* | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * -;* ------------------------------------------------- * -;* | x27 | x28 | FP | LR | * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * -;* ------------------------------------------------- * -;* | 0xa0| 0xa4| 0xa8| 0xac| 0xb0| 0xb4| 0xb8| 0xbc| * -;* ------------------------------------------------- * -;* | base | limit | dealloc | fiber data| * -;* ------------------------------------------------- * -;* ------------------------------------------------- * -;* | 48 | 49 | 50 | 51 | | | * -;* ------------------------------------------------- * -;* | 0xc0| 0xc4| 0xc8| 0xcc| | | * -;* ------------------------------------------------- * -;* | PC | align | | | * -;* ------------------------------------------------- * -;* * -;******************************************************* - - AREA |.text|, CODE, READONLY, ALIGN=4, CODEALIGN - EXPORT make_fcontext - IMPORT _exit - -make_fcontext proc - ; save stack top address to x3 - mov x3, x0 - - ; shift address in x0 (allocated stack) to lower 16 byte boundary - and x0, x0, ~0xF - - ; reserve space for context-data on context-stack - sub x0, x0, #0xd0 - - ; save top address of context_stack as 'base' - str x3, [x0, #0xa0] - ; save bottom address of context-stack as 'limit' and 'dealloction stack' - sub x3, x3, x1 - stp x3, x3, [x0, #0xa8] - ; save 0 as 'fiber data' - str xzr, [x0, #0xb8] - - ; third arg of make_fcontext() == address of context-function - ; store address as x19 for trampoline - str x2, [x0, #0x40] - ; store trampoline address as pc - adr x2, trampoline - str x2, [x0, #0xc0] - - ; save address of finish as return-address for context-function - ; will be entered after context-function returns (LR register) - adr x1, finish - str x1, [x0, #0x98] - - ret x30 ; return pointer to context-data (x0) - -trampoline - stp fp, lr, [sp, #-0x10]! - mov fp, sp - blr x19 - -finish - ; exit code is zero - mov x0, #0 - ; exit application - bl _exit - ENDP - END +; Copyright Edward Nevill + Oliver Kowalke 2015 +; Distributed under the Boost Software License, Version 1.0. +; (See accompanying file LICENSE_1_0.txt or copy at +; http://www.boost.org/LICENSE_1_0.txt) + +;******************************************************* +;* * +;* ------------------------------------------------- * +;* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * +;* ------------------------------------------------- * +;* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * +;* ------------------------------------------------- * +;* | d8 | d9 | d10 | d11 | * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * +;* ------------------------------------------------- * +;* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * +;* ------------------------------------------------- * +;* | d12 | d13 | d14 | d15 | * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * +;* ------------------------------------------------- * +;* | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * +;* ------------------------------------------------- * +;* | x19 | x20 | x21 | x22 | * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * +;* ------------------------------------------------- * +;* | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * +;* ------------------------------------------------- * +;* | x23 | x24 | x25 | x26 | * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * +;* ------------------------------------------------- * +;* | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * +;* ------------------------------------------------- * +;* | x27 | x28 | FP | LR | * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * +;* ------------------------------------------------- * +;* | 0xa0| 0xa4| 0xa8| 0xac| 0xb0| 0xb4| 0xb8| 0xbc| * +;* ------------------------------------------------- * +;* | base | limit | dealloc | fiber data| * +;* ------------------------------------------------- * +;* ------------------------------------------------- * +;* | 48 | 49 | 50 | 51 | | | * +;* ------------------------------------------------- * +;* | 0xc0| 0xc4| 0xc8| 0xcc| | | * +;* ------------------------------------------------- * +;* | PC | align | | | * +;* ------------------------------------------------- * +;* * +;******************************************************* + + AREA |.text|, CODE, READONLY, ALIGN=4, CODEALIGN + EXPORT make_fcontext + IMPORT _exit + +make_fcontext proc + ; save stack top address to x3 + mov x3, x0 + + ; shift address in x0 (allocated stack) to lower 16 byte boundary + and x0, x0, ~0xF + + ; reserve space for context-data on context-stack + sub x0, x0, #0xd0 + + ; save top address of context_stack as 'base' + str x3, [x0, #0xa0] + ; save bottom address of context-stack as 'limit' and 'dealloction stack' + sub x3, x3, x1 + stp x3, x3, [x0, #0xa8] + ; save 0 as 'fiber data' + str xzr, [x0, #0xb8] + + ; third arg of make_fcontext() == address of context-function + ; store address as x19 for trampoline + str x2, [x0, #0x40] + ; store trampoline address as pc + adr x2, trampoline + str x2, [x0, #0xc0] + + ; save address of finish as return-address for context-function + ; will be entered after context-function returns (LR register) + adr x1, finish + str x1, [x0, #0x98] + + ret x30 ; return pointer to context-data (x0) + +trampoline + stp fp, lr, [sp, #-0x10]! + mov fp, sp + blr x19 + +finish + ; exit code is zero + mov x0, #0 + ; exit application + bl _exit + ENDP + END From 94ecc1fe7d01a69b10d0e577c935ba6aa759964f Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 7 Sep 2024 11:53:35 +0200 Subject: [PATCH 07/24] Autotools: Sync CS for PHP_PWRITE_TEST and PHP_PREAD_TEST (#15774) - AS_* macros used - Arguments quoted - Cache variable ac_cv_pread renamed to php_cv_func_pread - Cache variables ac_cv_pwrite renamed to php_cv_func_pwrite --- UPGRADING.INTERNALS | 2 + build/php.m4 | 94 ++++++++++++++++++++------------------------- 2 files changed, 43 insertions(+), 53 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index ea0be872843a3..84aeb202b8ca6 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -222,6 +222,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES - ac_cv_func_getaddrinfo -> php_cv_func_getaddrinfo - ac_cv_have_broken_gcc_strlen_opt -> php_cv_have_broken_gcc_strlen_opt - ac_cv_have_pcre2_jit -> php_cv_have_pcre2_jit + - ac_cv_pread -> php_cv_func_pread + - ac_cv_pwrite -> php_cv_func_pwrite - ac_cv_syscall_shadow_stack_exists -> php_cv_have_shadow_stack_syscall - ac_cv_time_r_type -> php_cv_time_r_type - ac_cv_write_stdout -> php_cv_have_write_stdout diff --git a/build/php.m4 b/build/php.m4 index aa8057fa5ff52..ad2bfd0ac3f01 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -1137,8 +1137,8 @@ dnl PHP_DOES_PWRITE_WORK dnl dnl Internal. dnl -AC_DEFUN([PHP_DOES_PWRITE_WORK],[ - AC_RUN_IFELSE([AC_LANG_SOURCE([ +AC_DEFUN([PHP_DOES_PWRITE_WORK], [ +AC_RUN_IFELSE([AC_LANG_SOURCE([ #include #include #include @@ -1155,13 +1155,10 @@ $1 if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) return 1; return 0; } - ])],[ - ac_cv_pwrite=yes - ],[ - ac_cv_pwrite=no - ],[ - ac_cv_pwrite=no - ]) + ])], + [php_cv_func_pwrite=yes], + [php_cv_func_pwrite=no], + [php_cv_func_pwrite=no]) ]) dnl @@ -1169,9 +1166,9 @@ dnl PHP_DOES_PREAD_WORK dnl dnl Internal. dnl -AC_DEFUN([PHP_DOES_PREAD_WORK],[ - echo test > conftest_pread - AC_RUN_IFELSE([AC_LANG_SOURCE([[ +AC_DEFUN([PHP_DOES_PREAD_WORK], [ +echo test > conftest_pread +AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -1188,61 +1185,52 @@ $1 if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) return 1; return 0; } - ]])],[ - ac_cv_pread=yes - ],[ - ac_cv_pread=no - ],[ - ac_cv_pread=no - ]) + ]])], + [php_cv_func_pread=yes], + [php_cv_func_pread=no], + [php_cv_func_pread=no]) ]) dnl dnl PHP_PWRITE_TEST dnl -AC_DEFUN([PHP_PWRITE_TEST],[ - AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[ - PHP_DOES_PWRITE_WORK - if test "$ac_cv_pwrite" = "no"; then - PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);]) - if test "$ac_cv_pwrite" = "yes"; then - ac_cv_pwrite=64 - fi - fi +AC_DEFUN([PHP_PWRITE_TEST], [ +AC_CACHE_CHECK([whether pwrite works], [php_cv_func_pwrite], [ + PHP_DOES_PWRITE_WORK + AS_VAR_IF([php_cv_func_pwrite], [no], [ + PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);]) + AS_VAR_IF([php_cv_func_pwrite], [yes], [php_cv_func_pwrite=64]) ]) +]) - if test "$ac_cv_pwrite" != "no"; then - AC_DEFINE([HAVE_PWRITE], [1], - [Define to 1 if you have the 'pwrite' function.]) - if test "$ac_cv_pwrite" = "64"; then - AC_DEFINE([PHP_PWRITE_64], [1], - [Define to 1 if 'pwrite' declaration with 'off64_t' is missing.]) - fi - fi +AS_VAR_IF([php_cv_func_pwrite], [no],, [ + AC_DEFINE([HAVE_PWRITE], [1], + [Define to 1 if you have the 'pwrite' function.]) + AS_VAR_IF([php_cv_func_pwrite], [64], + [AC_DEFINE([PHP_PWRITE_64], [1], + [Define to 1 if 'pwrite' declaration with 'off64_t' is missing.])]) +]) ]) dnl dnl PHP_PREAD_TEST dnl -AC_DEFUN([PHP_PREAD_TEST],[ - AC_CACHE_CHECK(whether pread works,ac_cv_pread,[ - PHP_DOES_PREAD_WORK - if test "$ac_cv_pread" = "no"; then - PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);]) - if test "$ac_cv_pread" = "yes"; then - ac_cv_pread=64 - fi - fi +AC_DEFUN([PHP_PREAD_TEST], [ +AC_CACHE_CHECK([whether pread works], [php_cv_func_pread], [ + PHP_DOES_PREAD_WORK + AS_VAR_IF([php_cv_func_pread], [no], [ + PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);]) + AS_VAR_IF([php_cv_func_pread], [yes], [php_cv_func_pread=64]) ]) +]) - if test "$ac_cv_pread" != "no"; then - AC_DEFINE([HAVE_PREAD], [1], - [Define to 1 if you have the 'pread' function.]) - if test "$ac_cv_pread" = "64"; then - AC_DEFINE([PHP_PREAD_64], [1], - [Define to 1 if 'pread' declaration with 'off64_t' is missing.]) - fi - fi +AS_VAR_IF([php_cv_func_pread], [no],, [ + AC_DEFINE([HAVE_PREAD], [1], + [Define to 1 if you have the 'pread' function.]) + AS_VAR_IF([php_cv_func_pread], [64], + [AC_DEFINE([PHP_PREAD_64], [1], + [Define to 1 if 'pread' declaration with 'off64_t' is missing.])]) +]) ]) dnl From f1b4e1276c78302686764b53c1491fe0ac3f3c31 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 6 Sep 2024 21:14:01 +0200 Subject: [PATCH 08/24] Simplify bcmath_check_scale() The scale is default-initialized to 0, so we can simplify the code a bit. --- ext/bcmath/bcmath.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index 08f6b7c14cb90..fcf38a1dab8c8 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -1305,9 +1305,9 @@ static zend_always_inline zend_result bc_num_from_obj_or_str_or_long_with_err( return SUCCESS; } -static zend_always_inline zend_result bcmath_check_scale(zend_long scale, bool scale_is_null, uint32_t arg_num) +static zend_always_inline zend_result bcmath_check_scale(zend_long scale, uint32_t arg_num) { - if (UNEXPECTED(!scale_is_null && (scale < 0 || scale > INT_MAX))) { + if (UNEXPECTED(scale < 0 || scale > INT_MAX)) { zend_argument_value_error(arg_num, "must be between 0 and %d", INT_MAX); return FAILURE; } @@ -1359,7 +1359,7 @@ static void bcmath_number_calc_method(INTERNAL_FUNCTION_PARAMETERS, uint8_t opco if (bc_num_from_obj_or_str_or_long_with_err(&num, &num_full_scale, num_obj, num_str, num_lval, 1) == FAILURE) { goto fail; } - if (bcmath_check_scale(scale_lval, scale_is_null, 2) == FAILURE) { + if (bcmath_check_scale(scale_lval, 2) == FAILURE) { goto fail; } @@ -1469,7 +1469,7 @@ PHP_METHOD(BcMath_Number, powmod) if (bc_num_from_obj_or_str_or_long_with_err(&modulus_num, NULL, modulus_obj, modulus_str, modulus_lval, 2) == FAILURE) { goto cleanup; } - if (bcmath_check_scale(scale_lval, scale_is_null, 3) == FAILURE) { + if (bcmath_check_scale(scale_lval, 3) == FAILURE) { goto cleanup; } @@ -1530,7 +1530,7 @@ PHP_METHOD(BcMath_Number, sqrt) Z_PARAM_LONG_OR_NULL(scale_lval, scale_is_null); ZEND_PARSE_PARAMETERS_END(); - if (bcmath_check_scale(scale_lval, scale_is_null, 1) == FAILURE) { + if (bcmath_check_scale(scale_lval, 1) == FAILURE) { RETURN_THROWS(); } @@ -1584,7 +1584,7 @@ PHP_METHOD(BcMath_Number, compare) if (bc_num_from_obj_or_str_or_long_with_err(&num, &num_full_scale, num_obj, num_str, num_lval, 1) == FAILURE) { goto fail; } - if (bcmath_check_scale(scale_lval, scale_is_null, 2) == FAILURE) { + if (bcmath_check_scale(scale_lval, 2) == FAILURE) { goto fail; } From 2e88916b58551e57252d4c10215e46ad664c70ee Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 6 Sep 2024 21:19:18 +0200 Subject: [PATCH 09/24] Move bcmath_check_scale() --- ext/bcmath/bcmath.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index fcf38a1dab8c8..cd9fcde9dcc75 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -148,6 +148,15 @@ PHP_MINFO_FUNCTION(bcmath) } /* }}} */ +static zend_always_inline zend_result bcmath_check_scale(zend_long scale, uint32_t arg_num) +{ + if (UNEXPECTED(scale < 0 || scale > INT_MAX)) { + zend_argument_value_error(arg_num, "must be between 0 and %d", INT_MAX); + return FAILURE; + } + return SUCCESS; +} + static void php_long2num(bc_num *num, zend_long lval) { *num = bc_long2num(lval); @@ -1305,15 +1314,6 @@ static zend_always_inline zend_result bc_num_from_obj_or_str_or_long_with_err( return SUCCESS; } -static zend_always_inline zend_result bcmath_check_scale(zend_long scale, uint32_t arg_num) -{ - if (UNEXPECTED(scale < 0 || scale > INT_MAX)) { - zend_argument_value_error(arg_num, "must be between 0 and %d", INT_MAX); - return FAILURE; - } - return SUCCESS; -} - PHP_METHOD(BcMath_Number, __construct) { zend_string *str = NULL; From ac0931d37aaf63aab22123a74dd89e5408ab52b8 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 6 Sep 2024 21:19:24 +0200 Subject: [PATCH 10/24] Reuse bcmath_check_scale() --- ext/bcmath/bcmath.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index cd9fcde9dcc75..b7fef270c93d3 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -197,8 +197,7 @@ PHP_FUNCTION(bcadd) if (scale_param_is_null) { scale = BCG(bc_precision); - } else if (scale_param < 0 || scale_param > INT_MAX) { - zend_argument_value_error(3, "must be between 0 and %d", INT_MAX); + } else if (bcmath_check_scale(scale_param, 3) == FAILURE) { RETURN_THROWS(); } else { scale = (int) scale_param; @@ -247,8 +246,7 @@ PHP_FUNCTION(bcsub) if (scale_param_is_null) { scale = BCG(bc_precision); - } else if (scale_param < 0 || scale_param > INT_MAX) { - zend_argument_value_error(3, "must be between 0 and %d", INT_MAX); + } else if (bcmath_check_scale(scale_param, 3) == FAILURE) { RETURN_THROWS(); } else { scale = (int) scale_param; @@ -297,8 +295,7 @@ PHP_FUNCTION(bcmul) if (scale_param_is_null) { scale = BCG(bc_precision); - } else if (scale_param < 0 || scale_param > INT_MAX) { - zend_argument_value_error(3, "must be between 0 and %d", INT_MAX); + } else if (bcmath_check_scale(scale_param, 3) == FAILURE) { RETURN_THROWS(); } else { scale = (int) scale_param; @@ -347,8 +344,7 @@ PHP_FUNCTION(bcdiv) if (scale_param_is_null) { scale = BCG(bc_precision); - } else if (scale_param < 0 || scale_param > INT_MAX) { - zend_argument_value_error(3, "must be between 0 and %d", INT_MAX); + } else if (bcmath_check_scale(scale_param, 3) == FAILURE) { RETURN_THROWS(); } else { scale = (int) scale_param; @@ -402,8 +398,7 @@ PHP_FUNCTION(bcmod) if (scale_param_is_null) { scale = BCG(bc_precision); - } else if (scale_param < 0 || scale_param > INT_MAX) { - zend_argument_value_error(3, "must be between 0 and %d", INT_MAX); + } else if (bcmath_check_scale(scale_param, 3) == FAILURE) { RETURN_THROWS(); } else { scale = (int) scale_param; @@ -458,8 +453,7 @@ PHP_FUNCTION(bcpowmod) if (scale_param_is_null) { scale = BCG(bc_precision); - } else if (scale_param < 0 || scale_param > INT_MAX) { - zend_argument_value_error(4, "must be between 0 and %d", INT_MAX); + } else if (bcmath_check_scale(scale_param, 4) == FAILURE) { RETURN_THROWS(); } else { scale = (int) scale_param; @@ -535,8 +529,7 @@ PHP_FUNCTION(bcpow) if (scale_param_is_null) { scale = BCG(bc_precision); - } else if (scale_param < 0 || scale_param > INT_MAX) { - zend_argument_value_error(3, "must be between 0 and %d", INT_MAX); + } else if (bcmath_check_scale(scale_param, 3) == FAILURE) { RETURN_THROWS(); } else { scale = (int) scale_param; @@ -597,8 +590,7 @@ PHP_FUNCTION(bcsqrt) if (scale_param_is_null) { scale = BCG(bc_precision); - } else if (scale_param < 0 || scale_param > INT_MAX) { - zend_argument_value_error(2, "must be between 0 and %d", INT_MAX); + } else if (bcmath_check_scale(scale_param, 2) == FAILURE) { RETURN_THROWS(); } else { scale = (int) scale_param; @@ -642,8 +634,7 @@ PHP_FUNCTION(bccomp) if (scale_param_is_null) { scale = BCG(bc_precision); - } else if (scale_param < 0 || scale_param > INT_MAX) { - zend_argument_value_error(3, "must be between 0 and %d", INT_MAX); + } else if (bcmath_check_scale(scale_param, 3) == FAILURE) { RETURN_THROWS(); } else { scale = (int) scale_param; @@ -783,8 +774,7 @@ PHP_FUNCTION(bcscale) old_scale = BCG(bc_precision); if (!new_scale_is_null) { - if (new_scale < 0 || new_scale > INT_MAX) { - zend_argument_value_error(1, "must be between 0 and %d", INT_MAX); + if (bcmath_check_scale(new_scale, 1) == FAILURE) { RETURN_THROWS(); } From dfe6c13850b182ec3400c7206c4d1e962d006d79 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Sat, 7 Sep 2024 15:25:02 +0200 Subject: [PATCH 11/24] Fix typo (#15780) * Fix typo * Implement conditional message * Use suggested code with ternary * Wrap ternary Co-authored-by: Peter Kokot --------- Co-authored-by: Peter Kokot --- win32/build/confutils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 2f333668d4552..5a28719f31bd9 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2096,7 +2096,9 @@ function generate_files() if (INVALID_CONFIG_ARGS.length) { STDOUT.WriteLine('WARNING'); - STDOUT.WriteLine('The following arguments is invalid, and therefore ignored:'); + STDOUT.WriteLine('The following ' + + (INVALID_CONFIG_ARGS.length > 1 ? 'arguments are' : 'argument is') + + ' invalid, and therefore ignored:'); for (var i = 0; i < INVALID_CONFIG_ARGS.length; ++i) { STDOUT.WriteLine(' ' + INVALID_CONFIG_ARGS[i]); From e358634cdce6a7505b7d422c23ec205a483ad2fc Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 7 Sep 2024 21:27:02 +0200 Subject: [PATCH 12/24] Sync Zend/*_i386_sysv_elf_gas.S with upstream (#15788) This is a sync with upstream already fixed in early 2024 which fixes 64-bit builds on 32-bit hosts. PHP's bundled config.guess sets the host_alias, for example, on Solaris systems to 64-bit if the compiler supports it even though the architecture is actually 32-bit. These assembly files resolve this situation in a build-system-agnostic way by including the architecture file that is supported by the compiler. --- Zend/asm/jump_i386_sysv_elf_gas.S | 6 ++++++ Zend/asm/make_i386_sysv_elf_gas.S | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Zend/asm/jump_i386_sysv_elf_gas.S b/Zend/asm/jump_i386_sysv_elf_gas.S index 47be9e77822e0..ed83717ce2b81 100644 --- a/Zend/asm/jump_i386_sysv_elf_gas.S +++ b/Zend/asm/jump_i386_sysv_elf_gas.S @@ -24,6 +24,10 @@ * * ****************************************************************************************/ +#ifdef __x86_64__ +#include "jump_x86_64_sysv_elf_gas.S" +#else + .file "jump_i386_sysv_elf_gas.S" .text .globl jump_fcontext @@ -91,3 +95,5 @@ jump_fcontext: /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits + +#endif diff --git a/Zend/asm/make_i386_sysv_elf_gas.S b/Zend/asm/make_i386_sysv_elf_gas.S index 9261e566c0d45..c6e0b36558a65 100644 --- a/Zend/asm/make_i386_sysv_elf_gas.S +++ b/Zend/asm/make_i386_sysv_elf_gas.S @@ -24,6 +24,10 @@ * * ****************************************************************************************/ +#ifdef __x86_64__ +#include "make_x86_64_sysv_elf_gas.S" +#else + .file "make_i386_sysv_elf_gas.S" .text .globl make_fcontext @@ -111,3 +115,5 @@ finish: /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits + +#endif From 6d6bf0530a66497817c62ba807d6253e86d630d5 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 8 Sep 2024 06:57:31 +0200 Subject: [PATCH 13/24] Autotools: Enable adding a list of paths in PHP_ADD_INCLUDE (#15777) This enables adding multiple include paths. For example: PHP_ADD_INCLUDE([ $abs_srcdir $abs_builddir $abs_srcdir/main $abs_builddir/main ], [1]) The 2nd argument "prepend" is now validated at Autoconf compile time instead of the configure time. --- UPGRADING.INTERNALS | 3 +++ build/php.m4 | 29 ++++++++++++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 84aeb202b8ca6..1083b15617ecc 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -200,6 +200,9 @@ PHP 8.4 INTERNALS UPGRADE NOTES - Autoconf macros PHP_NEW_EXTENSION, PHP_ADD_SOURCES, PHP_ADD_SOURCES_X, PHP_SELECT_SAPI now have the source files and flags arguments normalized so the list of items can be passed as a blank-or-newline-separated list. + - Autoconf macro PHP_ADD_INCLUDE now takes also a blank-or-newline-separated + list of include directories instead of a single directory. The "prepend" + argument is validated at Autoconf compile time. - TSRM/tsrm.m4 file and its TSRM_CHECK_PTHREADS macro have been removed. - Added pkg-config support to find libpq for the pdo_pgsql and pgsql extensions. The libpq paths can be customized with the PGSQL_CFLAGS and diff --git a/build/php.m4 b/build/php.m4 index ad2bfd0ac3f01..82c662cc92cba 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -467,21 +467,20 @@ AC_DEFUN([PHP_UTILIZE_RPATHS],[ ]) dnl -dnl PHP_ADD_INCLUDE(path [,before]) -dnl -dnl Add an include path. If before is 1, add in the beginning of INCLUDES. -dnl -AC_DEFUN([PHP_ADD_INCLUDE],[ - if test "$1" != "/usr/include"; then - PHP_EXPAND_PATH($1, ai_p) - PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [ - if test "$2"; then - INCLUDES="-I$ai_p $INCLUDES" - else - INCLUDES="$INCLUDES -I$ai_p" - fi - ]) - fi +dnl PHP_ADD_INCLUDE(paths [,prepend]) +dnl +dnl Add blank-or-newline-separated list of include paths. If "prepend" is given, +dnl paths are prepended to the beginning of INCLUDES. +dnl +AC_DEFUN([PHP_ADD_INCLUDE], [ +for include_path in m4_normalize(m4_expand([$1])); do + AS_IF([test "$include_path" != "/usr/include"], [ + PHP_EXPAND_PATH([$include_path], [ai_p]) + PHP_RUN_ONCE([INCLUDEPATH], [$ai_p], [m4_ifnblank([$2], + [INCLUDES="-I$ai_p $INCLUDES"], + [INCLUDES="$INCLUDES -I$ai_p"])]) + ]) +done ]) dnl From 0f3b2e506b6f87a3306ce44ec6e82d344bded225 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 8 Sep 2024 08:31:21 +0200 Subject: [PATCH 14/24] Autotools: Move extension setup to main check (#15797) Also, redundant PHP_MBREGEX check is removed and wrapped in a single "if" check. --- ext/mbstring/config.m4 | 125 ++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 64 deletions(-) diff --git a/ext/mbstring/config.m4 b/ext/mbstring/config.m4 index b526db0b200c0..3030147028310 100644 --- a/ext/mbstring/config.m4 +++ b/ext/mbstring/config.m4 @@ -18,69 +18,38 @@ AC_DEFUN([PHP_MBSTRING_ADD_CFLAG], [ PHP_MBSTRING_CFLAGS="$PHP_MBSTRING_CFLAGS $1" ]) -AC_DEFUN([PHP_MBSTRING_EXTENSION], [ - PHP_NEW_EXTENSION([mbstring], - [$PHP_MBSTRING_BASE_SOURCES $PHP_MBSTRING_SOURCES], - [$ext_shared],, - [$PHP_MBSTRING_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) - PHP_SUBST([MBSTRING_SHARED_LIBADD]) - - for dir in $PHP_MBSTRING_EXTRA_BUILD_DIRS; do - PHP_ADD_BUILD_DIR([$ext_builddir/$dir], [1]) - done - - for dir in $PHP_MBSTRING_EXTRA_INCLUDES; do - PHP_ADD_INCLUDE([$ext_srcdir/$dir]) - PHP_ADD_INCLUDE([$ext_builddir/$dir]) - done - - out="php_config.h" - - if test "$ext_shared" != "no" && test -f "$ext_builddir/config.h.in"; then - out="$abs_builddir/config.h" - fi - - cat > $ext_builddir/libmbfl/config.h < - #include - ], - [return (intptr_t)(ONIG_ENCODING_KOI8 + 1);])], - [php_cv_lib_onig_invalid_koi8=no], - [php_cv_lib_onig_invalid_koi8=yes]) - LIBS=$save_old_LIBS - CFLAGS=$save_old_CFLAGS]) - AS_VAR_IF([php_cv_lib_onig_invalid_koi8], [yes], - [AC_DEFINE([PHP_ONIG_BAD_KOI8_ENTRY], [1], - [Define to 1 if oniguruma has an invalid entry for KOI8 encoding.])]) - - PHP_MBSTRING_ADD_CFLAG([-DONIG_ESCAPE_UCHAR_COLLISION=1]) - PHP_MBSTRING_ADD_CFLAG([-DUChar=OnigUChar]) - - AC_DEFINE([HAVE_MBREGEX], [1], - [Define to 1 if mbstring has multibyte regex support enabled.]) - - PHP_MBSTRING_ADD_BASE_SOURCES([php_mbregex.c]) - PHP_INSTALL_HEADERS([ext/mbstring], [php_mbregex.h php_onig_compat.h]) - fi + PKG_CHECK_MODULES([ONIG], [oniguruma]) + PHP_EVAL_LIBLINE([$ONIG_LIBS], [MBSTRING_SHARED_LIBADD]) + PHP_EVAL_INCLINE([$ONIG_CFLAGS]) + + AC_CACHE_CHECK([if oniguruma has an invalid entry for KOI8 encoding], + [php_cv_lib_onig_invalid_koi8], + [save_old_LIBS=$LIBS + LIBS="$LIBS $MBSTRING_SHARED_LIBADD" + save_old_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $ONIG_CFLAGS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + #include + #include + ], + [return (intptr_t)(ONIG_ENCODING_KOI8 + 1);])], + [php_cv_lib_onig_invalid_koi8=no], + [php_cv_lib_onig_invalid_koi8=yes]) + LIBS=$save_old_LIBS + CFLAGS=$save_old_CFLAGS]) + AS_VAR_IF([php_cv_lib_onig_invalid_koi8], [yes], + [AC_DEFINE([PHP_ONIG_BAD_KOI8_ENTRY], [1], + [Define to 1 if oniguruma has an invalid entry for KOI8 encoding.])]) + + PHP_MBSTRING_ADD_CFLAG([-DONIG_ESCAPE_UCHAR_COLLISION=1]) + PHP_MBSTRING_ADD_CFLAG([-DUChar=OnigUChar]) + + AC_DEFINE([HAVE_MBREGEX], [1], + [Define to 1 if mbstring has multibyte regex support enabled.]) + + PHP_MBSTRING_ADD_BASE_SOURCES([php_mbregex.c]) + PHP_INSTALL_HEADERS([ext/mbstring], [php_mbregex.h php_onig_compat.h]) ]) AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [ @@ -173,10 +142,38 @@ if test "$PHP_MBSTRING" != "no"; then PHP_MBSTRING_ADD_BASE_SOURCES([mbstring.c php_unicode.c mb_gpc.c]) - AS_VAR_IF([PHP_MBREGEX], [no],, [PHP_MBSTRING_SETUP_MBREGEX]) + AS_VAR_IF([PHP_MBREGEX], [yes], [PHP_MBSTRING_SETUP_MBREGEX]) dnl libmbfl is required PHP_MBSTRING_SETUP_LIBMBFL - PHP_MBSTRING_EXTENSION + + PHP_NEW_EXTENSION([mbstring], + [$PHP_MBSTRING_BASE_SOURCES $PHP_MBSTRING_SOURCES], + [$ext_shared],, + [$PHP_MBSTRING_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) + + PHP_SUBST([MBSTRING_SHARED_LIBADD]) + + for dir in $PHP_MBSTRING_EXTRA_BUILD_DIRS; do + PHP_ADD_BUILD_DIR([$ext_builddir/$dir], [1]) + done + + for dir in $PHP_MBSTRING_EXTRA_INCLUDES; do + PHP_ADD_INCLUDE([$ext_srcdir/$dir]) + PHP_ADD_INCLUDE([$ext_builddir/$dir]) + done + + out="php_config.h" + + if test "$ext_shared" != "no" && test -f "$ext_builddir/config.h.in"; then + out="$abs_builddir/config.h" + fi + + cat > $ext_builddir/libmbfl/config.h < Date: Sun, 8 Sep 2024 00:06:22 +0200 Subject: [PATCH 15/24] Fix bug #61525: SOAP functions require at least one space after HTTP header colon HTTP/1.1 does not require a single whitespace after the colon, and SoapServer does implement HTTP/1.1. The header value is already correctly whitespace-trimmed, so no behaviour change happens w.r.t. header values. Closes GH-15793. --- NEWS | 4 ++++ ext/soap/php_http.c | 24 +++++++++++----------- ext/soap/tests/bugs/bug61525.phpt | 33 +++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 ext/soap/tests/bugs/bug61525.phpt diff --git a/NEWS b/NEWS index 65a0a1c1d4f14..1a2422c653f58 100644 --- a/NEWS +++ b/NEWS @@ -49,6 +49,10 @@ PHP NEWS . Fixed bug GH-15718 (Segfault on ReflectionProperty::get{Hook,Hooks}() on dynamic properties). (DanielEScherzer) +- SOAP: + . Fixed bug #61525 (SOAP functions require at least one space after HTTP + header colon). (nielsdos) + - Standard: . Fixed bug GH-15552 (Signed integer overflow in ext/standard/scanf.c). (cmb) . Implemented GH-15685 (improve proc_open error reporting on Windows). (cmb) diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 60e8044a82504..bd548b5b303f1 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -980,7 +980,7 @@ int make_http_soap_request(zval *this_ptr, */ cookie_itt = ZSTR_VAL(http_headers); - while ((cookie_itt = get_http_header_value_nodup(cookie_itt, "Set-Cookie: ", &cookie_len))) { + while ((cookie_itt = get_http_header_value_nodup(cookie_itt, "Set-Cookie:", &cookie_len))) { zval *cookies = Z_CLIENT_COOKIES_P(this_ptr); SEPARATE_ARRAY(cookies); @@ -1049,7 +1049,7 @@ int make_http_soap_request(zval *this_ptr, if (http_1_1) { http_close = FALSE; if (use_proxy && !use_ssl) { - connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection: "); + connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection:"); if (connection) { if (strncasecmp(connection, "close", sizeof("close")-1) == 0) { http_close = TRUE; @@ -1058,7 +1058,7 @@ int make_http_soap_request(zval *this_ptr, } } if (http_close == FALSE) { - connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection: "); + connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection:"); if (connection) { if (strncasecmp(connection, "close", sizeof("close")-1) == 0) { http_close = TRUE; @@ -1069,7 +1069,7 @@ int make_http_soap_request(zval *this_ptr, } else { http_close = TRUE; if (use_proxy && !use_ssl) { - connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection: "); + connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection:"); if (connection) { if (strncasecmp(connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) { http_close = FALSE; @@ -1078,7 +1078,7 @@ int make_http_soap_request(zval *this_ptr, } } if (http_close == TRUE) { - connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection: "); + connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection:"); if (connection) { if (strncasecmp(connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) { http_close = FALSE; @@ -1121,7 +1121,7 @@ int make_http_soap_request(zval *this_ptr, if (http_status >= 300 && http_status < 400) { char *loc; - if ((loc = get_http_header_value(ZSTR_VAL(http_headers), "Location: ")) != NULL) { + if ((loc = get_http_header_value(ZSTR_VAL(http_headers), "Location:")) != NULL) { php_url *new_url = php_url_parse(loc); if (new_url != NULL) { @@ -1170,7 +1170,7 @@ int make_http_soap_request(zval *this_ptr, zval *digest = Z_CLIENT_DIGEST_P(this_ptr); zval *login = Z_CLIENT_LOGIN_P(this_ptr); zval *password = Z_CLIENT_PASSWORD_P(this_ptr); - char *auth = get_http_header_value(ZSTR_VAL(http_headers), "WWW-Authenticate: "); + char *auth = get_http_header_value(ZSTR_VAL(http_headers), "WWW-Authenticate:"); if (auth && strstr(auth, "Digest") == auth && Z_TYPE_P(digest) != IS_ARRAY && Z_TYPE_P(login) == IS_STRING && Z_TYPE_P(password) == IS_STRING) { char *s; @@ -1240,7 +1240,7 @@ int make_http_soap_request(zval *this_ptr, smart_str_free(&soap_headers_z); /* Check and see if the server even sent a xml document */ - content_type = get_http_header_value(ZSTR_VAL(http_headers), "Content-Type: "); + content_type = get_http_header_value(ZSTR_VAL(http_headers), "Content-Type:"); if (content_type) { char *pos = NULL; int cmplen; @@ -1270,7 +1270,7 @@ int make_http_soap_request(zval *this_ptr, } /* Decompress response */ - content_encoding = get_http_header_value(ZSTR_VAL(http_headers), "Content-Encoding: "); + content_encoding = get_http_header_value(ZSTR_VAL(http_headers), "Content-Encoding:"); if (content_encoding) { zval func; zval retval; @@ -1430,18 +1430,18 @@ static zend_string* get_http_body(php_stream *stream, int close, char *headers) int header_close = close, header_chunked = 0, header_length = 0, http_buf_size = 0; if (!close) { - header = get_http_header_value(headers, "Connection: "); + header = get_http_header_value(headers, "Connection:"); if (header) { if(!strncasecmp(header, "close", sizeof("close")-1)) header_close = 1; efree(header); } } - header = get_http_header_value(headers, "Transfer-Encoding: "); + header = get_http_header_value(headers, "Transfer-Encoding:"); if (header) { if(!strncasecmp(header, "chunked", sizeof("chunked")-1)) header_chunked = 1; efree(header); } - header = get_http_header_value(headers, "Content-Length: "); + header = get_http_header_value(headers, "Content-Length:"); if (header) { header_length = atoi(header); efree(header); diff --git a/ext/soap/tests/bugs/bug61525.phpt b/ext/soap/tests/bugs/bug61525.phpt new file mode 100644 index 0000000000000..4b5c19e86a4eb --- /dev/null +++ b/ext/soap/tests/bugs/bug61525.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #61525 (SOAP functions require at least one space after HTTP header colon) +--EXTENSIONS-- +soap +--SKIPIF-- + +--FILE-- + + + + + 7 + + + +XML; + +$length = strlen($response); +$server_response = "data://text/xml;base64," . base64_encode("HTTP/1.1 200 OK\r\nConnection:close\r\nContent-Length:$length\r\n\r\n$response"); +['pid' => $pid, 'uri' => $uri] = http_server([$server_response]); +$client = new SoapClient(NULL, ['location' => $uri, 'uri' => $uri]); +var_dump($client->Add(3, 4)); +http_server_kill($pid); +?> +--EXPECT-- +int(7) From 50b3a0d011127b69e8432c37f98c87725981962f Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 8 Sep 2024 16:11:25 +0200 Subject: [PATCH 16/24] Add comments about internal headers (GH-15689) A common convention is to name internal C header files as `*_int.h`. Since a couple of these are actually installed, we add comments that this is not supposed to happen, (a) to avoid installing further internal headers, and (b) to pave the way to fix this in the next major PHP version. Somewhat special is php_gmp_int.h, where "int" is meant as abbreviation for "interface". Another common convention is appending `_priv` or `_private`, but since there have not been any issues regarding these headers so far, we refrain from adding respective comments to these headers. Anyhow, it might be a good idea to introduce some common naming convention for such internal/private headers. --- Zend/zend_strtod_int.h | 2 ++ ext/gmp/php_gmp_int.h | 2 ++ ext/pdo_dblib/php_pdo_dblib_int.h | 2 ++ ext/pdo_firebird/php_pdo_firebird_int.h | 2 ++ ext/pdo_mysql/php_pdo_mysql_int.h | 2 ++ ext/pdo_odbc/php_pdo_odbc_int.h | 2 ++ ext/pdo_pgsql/php_pdo_pgsql_int.h | 2 ++ ext/standard/php_dir_int.h | 2 ++ main/streams/php_streams_int.h | 2 ++ 9 files changed, 18 insertions(+) diff --git a/Zend/zend_strtod_int.h b/Zend/zend_strtod_int.h index 79b993f7dbd9f..06a02618e9e6a 100644 --- a/Zend/zend_strtod_int.h +++ b/Zend/zend_strtod_int.h @@ -16,6 +16,8 @@ +----------------------------------------------------------------------+ */ +/* internal header; not supposed to be installed; FIXME but unfortunately is */ + #ifndef ZEND_STRTOD_INT_H #define ZEND_STRTOD_INT_H diff --git a/ext/gmp/php_gmp_int.h b/ext/gmp/php_gmp_int.h index d67fdd5c62236..32f1d32f592ab 100644 --- a/ext/gmp/php_gmp_int.h +++ b/ext/gmp/php_gmp_int.h @@ -1,3 +1,5 @@ +/* interface header; needs to be installed; FIXME rename? */ + #ifndef incl_PHP_GMP_INT_H #define incl_PHP_GMP_INT_H diff --git a/ext/pdo_dblib/php_pdo_dblib_int.h b/ext/pdo_dblib/php_pdo_dblib_int.h index 8f8d0e3c827eb..2067d944c7182 100644 --- a/ext/pdo_dblib/php_pdo_dblib_int.h +++ b/ext/pdo_dblib/php_pdo_dblib_int.h @@ -15,6 +15,8 @@ +----------------------------------------------------------------------+ */ +/* internal header; not supposed to be installed */ + #ifndef PHP_PDO_DBLIB_INT_H #define PHP_PDO_DBLIB_INT_H diff --git a/ext/pdo_firebird/php_pdo_firebird_int.h b/ext/pdo_firebird/php_pdo_firebird_int.h index dc1e4bb7f4086..2b8d00a4e37e6 100644 --- a/ext/pdo_firebird/php_pdo_firebird_int.h +++ b/ext/pdo_firebird/php_pdo_firebird_int.h @@ -14,6 +14,8 @@ +----------------------------------------------------------------------+ */ +/* internal header; not supposed to be installed */ + #ifndef PHP_PDO_FIREBIRD_INT_H #define PHP_PDO_FIREBIRD_INT_H diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h index b2e15e3080d5a..9c78813d5f249 100644 --- a/ext/pdo_mysql/php_pdo_mysql_int.h +++ b/ext/pdo_mysql/php_pdo_mysql_int.h @@ -16,6 +16,8 @@ +----------------------------------------------------------------------+ */ +/* internal header; not supposed to be installed */ + #ifndef PHP_PDO_MYSQL_INT_H #define PHP_PDO_MYSQL_INT_H diff --git a/ext/pdo_odbc/php_pdo_odbc_int.h b/ext/pdo_odbc/php_pdo_odbc_int.h index e082ae7512355..473d70ff70763 100644 --- a/ext/pdo_odbc/php_pdo_odbc_int.h +++ b/ext/pdo_odbc/php_pdo_odbc_int.h @@ -14,6 +14,8 @@ +----------------------------------------------------------------------+ */ +/* internal header; not supposed to be installed */ + #ifdef PHP_WIN32 # define PDO_ODBC_TYPE "Win32" #endif diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h index 3cd0b005fcc55..fc9f1664cc3d4 100644 --- a/ext/pdo_pgsql/php_pdo_pgsql_int.h +++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h @@ -16,6 +16,8 @@ +----------------------------------------------------------------------+ */ +/* internal header; not supposed to be installed */ + #ifndef PHP_PDO_PGSQL_INT_H #define PHP_PDO_PGSQL_INT_H diff --git a/ext/standard/php_dir_int.h b/ext/standard/php_dir_int.h index a359cb725d085..f9d63e78661a1 100644 --- a/ext/standard/php_dir_int.h +++ b/ext/standard/php_dir_int.h @@ -12,6 +12,8 @@ +----------------------------------------------------------------------+ */ +/* internal header; not supposed to be installed; FIXME but unfortunately is */ + #ifndef PHP_DIR_INT_H #define PHP_DIR_INT_H diff --git a/main/streams/php_streams_int.h b/main/streams/php_streams_int.h index a3c55bdd4f066..7580088fba316 100644 --- a/main/streams/php_streams_int.h +++ b/main/streams/php_streams_int.h @@ -14,6 +14,8 @@ +----------------------------------------------------------------------+ */ +/* internal header; not supposed to be installed; FIXME but unfortunately is */ + #if ZEND_DEBUG #define emalloc_rel_orig(size) \ From edcd6cc564fed69771035d1dec04ac978bd23585 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 8 Sep 2024 16:16:40 +0200 Subject: [PATCH 17/24] gai_strerror() is not thread-safe on Windows (GH-15568) First we refactor to have only a single usage of `PHP_GAI_STRERROR()` left; then we drop the macro in favor of calling the different functions conditionally in an ad-hoc style. This is necessary because the return value of `php_win32_error_to_msg` needs to be freed by the caller. The error messages are no more inline with other error messages, since `gai_strerror()` apparently always appends a period and a space. We also properly configure IPv4/v6 on Windows. Since WSPiApi.h has been created in 2000, so we can safely assume that it is available everywhere nowadays. Furthermore, `gai_strerror()` is available regardless of whether there is IPv6 support. --- main/network.c | 21 ++++++++++++++------- win32/build/config.w32 | 6 +----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/main/network.c b/main/network.c index 9ca2b53b6ea5e..fd2e49d79d20b 100644 --- a/main/network.c +++ b/main/network.c @@ -88,10 +88,7 @@ const struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */ #endif #ifdef HAVE_GETADDRINFO -#ifdef HAVE_GAI_STRERROR -# define PHP_GAI_STRERROR(x) (gai_strerror(x)) -#else -# define PHP_GAI_STRERROR(x) (php_gai_strerror(x)) +# if !defined(PHP_WIN32) && !defined(HAVE_GAI_STRERROR) /* {{{ php_gai_strerror */ static const char *php_gai_strerror(int code) { @@ -129,7 +126,7 @@ static const char *php_gai_strerror(int code) return "Unknown error"; } /* }}} */ -#endif +# endif #endif /* {{{ php_network_freeaddresses */ @@ -193,16 +190,26 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka # endif if ((n = getaddrinfo(host, NULL, &hints, &res))) { +# if defined(PHP_WIN32) + char *gai_error = php_win32_error_to_msg(n); +# elif defined(HAVE_GAI_STRERROR) + const char *gai_error = gai_strerror(n); +# else + const char *gai_error = php_gai_strerror(n) +# endif if (error_string) { /* free error string received during previous iteration (if any) */ if (*error_string) { zend_string_release_ex(*error_string, 0); } - *error_string = strpprintf(0, "php_network_getaddresses: getaddrinfo for %s failed: %s", host, PHP_GAI_STRERROR(n)); + *error_string = strpprintf(0, "php_network_getaddresses: getaddrinfo for %s failed: %s", host, gai_error); php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(*error_string)); } else { - php_error_docref(NULL, E_WARNING, "php_network_getaddresses: getaddrinfo for %s failed: %s", host, PHP_GAI_STRERROR(n)); + php_error_docref(NULL, E_WARNING, "php_network_getaddresses: getaddrinfo for %s failed: %s", host, gai_error); } +# if PHP_WIN32 + php_win32_error_msg_free(gai_error); +# endif return 0; } else if (res == NULL) { if (error_string) { diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 08edb81d11947..043f18b275b9d 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -324,13 +324,9 @@ STDOUT.WriteBlankLines(1); /* Can we build with IPv6 support? */ ARG_ENABLE("ipv6", "Disable IPv6 support (default is turn it on if available)", "yes"); -var main_network_has_ipv6 = 0; +AC_DEFINE('HAVE_GAI_STRERROR', 1); if (PHP_IPV6 == "yes") { - main_network_has_ipv6 = CHECK_HEADER_ADD_INCLUDE("wspiapi.h", "CFLAGS") ? 1 : 0; -} -if (main_network_has_ipv6) { STDOUT.WriteLine("Enabling IPv6 support"); - AC_DEFINE('HAVE_GAI_STRERROR', 1); AC_DEFINE('HAVE_IPV6', 1); } From b97a60c9a382026b7711c4577013aa9eee14bd91 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 8 Sep 2024 20:13:48 +0200 Subject: [PATCH 18/24] Autotools: Check Apache version with apxs and HTTPD_VERSION variable (#15476) The apxs -q HTTPD_VERSION variable is available since Apache 2.4.17. This change obsoletes the PHP_AP_EXTRACT_VERSION macro and checks the version in the config.m4 file directly. Version is checked against the dotted format instead of the version number. --- UPGRADING.INTERNALS | 2 ++ build/php.m4 | 3 ++- sapi/apache2handler/config.m4 | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 1083b15617ecc..36bc61d194123 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -189,6 +189,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES symbol anymore and requires at least libxml2 2.9.4. - Autoconf macro PHP_SETUP_ICONV doesn't define the HAVE_ICONV symbol anymore. + - Autoconf macro PHP_AP_EXTRACT_VERSION is obsolete (use the + 'apxs -q HTTPD_VERSION'). - Autoconf macro PHP_OUTPUT is obsolete (use AC_CONFIG_FILES). - Autoconf macro PHP_PROG_SETUP now accepts an argument to set the minimum required PHP version during the build. diff --git a/build/php.m4 b/build/php.m4 index 82c662cc92cba..75c3a046c7b5c 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -2030,7 +2030,8 @@ dnl PHP_AP_EXTRACT_VERSION(/path/httpd) dnl dnl This macro is used to get a comparable version for Apache. dnl -AC_DEFUN([PHP_AP_EXTRACT_VERSION],[ +AC_DEFUN([PHP_AP_EXTRACT_VERSION], [m4_warn([obsolete], + [The macro 'PHP_AP_EXTRACT_VERSION' is obsolete. Use 'apxs -q HTTPD_VERSION']) AS_IF([test -x "$1"], [ ac_output=$($1 -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//') ac_IFS=$IFS diff --git a/sapi/apache2handler/config.m4 b/sapi/apache2handler/config.m4 index b5f1aed2e14e0..f9231aa9a3d97 100644 --- a/sapi/apache2handler/config.m4 +++ b/sapi/apache2handler/config.m4 @@ -53,9 +53,19 @@ if test "$PHP_APXS2" != "no"; then AS_CASE([$flag], [-D*], [APACHE_CPPFLAGS="$APACHE_CPPFLAGS $flag"]) done - dnl Check Apache version. - PHP_AP_EXTRACT_VERSION([$APXS_HTTPD]) - AS_VERSION_COMPARE([$APACHE_VERSION], [2004000], + dnl Check Apache version. The HTTPD_VERSION was added in Apache 2.4.17. + dnl Earlier versions can use the Apache HTTP Server command-line utility. + APACHE_VERSION=$($APXS -q HTTPD_VERSION 2>/dev/null) + AS_VAR_IF([APACHE_VERSION],, [ + ac_output=$($APXS_HTTPD -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//') + ac_IFS=$IFS + IFS="- /. +" + set $ac_output + IFS=$ac_IFS + APACHE_VERSION="$4.$5.$6" + ]) + AS_VERSION_COMPARE([$APACHE_VERSION], [2.4.0], [AC_MSG_ERROR([Please note that Apache version >= 2.4 is required])]) APXS_LIBEXECDIR='$(INSTALL_ROOT)'$($APXS -q LIBEXECDIR) From dfdec2d5500e857fa54c6de1a45cd81b5eb4c4b2 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 8 Sep 2024 21:05:30 +0200 Subject: [PATCH 19/24] Autotools: Refactor PHP_TEST_BUILD checks (#15798) - The libgd sanity check is there only to check whether all current linked libraries for the bundled libgd work together, otherwise it is probably even redundant a bit; this refactors it to a simpler AC_LINK_IFELSE check with default empty C program by Autoconf - The IBM DB2 sanity check is simplified with AC_CHECK_FUNC instead --- ext/gd/config.m4 | 16 +++++++++++----- ext/odbc/config.m4 | 9 ++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ext/gd/config.m4 b/ext/gd/config.m4 index c58310be57302..7da5b8cd1b2ec 100644 --- a/ext/gd/config.m4 +++ b/ext/gd/config.m4 @@ -287,11 +287,17 @@ dnl Various checks for GD features PHP_INSTALL_HEADERS([ext/gd], [php_gd.h libgd/]) - PHP_TEST_BUILD([foobar], - [], - [AC_MSG_FAILURE([GD library build test failed.])], - [$GD_SHARED_LIBADD], - [char foobar(void) { return '\0'; }]) + dnl Sanity check. + AC_CACHE_CHECK([whether build works], [php_cv_lib_gd_works], [ + LIBS_SAVED=$LIBS + LIBS="$GD_SHARED_LIBADD $LIBS" + AC_LINK_IFELSE([AC_LANG_PROGRAM()], + [php_cv_lib_gd_works=yes], + [php_cv_lib_gd_works=no]) + LIBS=$LIBS_SAVED + ]) + AS_VAR_IF([php_cv_lib_gd_works], [yes],, + [AC_MSG_FAILURE([GD library build test failed.])]) else extra_sources="gd_compat.c" PKG_CHECK_MODULES([GDLIB], [gdlib >= 2.1.0]) diff --git a/ext/odbc/config.m4 b/ext/odbc/config.m4 index ed72b777f5ded..eb6572c2c5c2d 100644 --- a/ext/odbc/config.m4 +++ b/ext/odbc/config.m4 @@ -202,15 +202,18 @@ PHP_ARG_WITH([ibm-db2], ODBC_TYPE=ibm-db2 ODBC_LIBS=-ldb2 - PHP_TEST_BUILD([SQLExecute], + dnl Sanity check. + old_LIBS=$LIBS + LIBS="$ODBC_LFLAGS $ODBC_LIBS $LIBS" + AC_CHECK_FUNC([SQLExecute], [AC_DEFINE([HAVE_IBMDB2], [1], [Define to 1 if the odbc extension uses the IBM DB2.])], [AC_MSG_FAILURE([ ODBC build test failed. You need to source your DB2 environment before running PHP configure: # . \$IBM_DB2/db2profile -])], - [$ODBC_LFLAGS $ODBC_LIBS]) +])]) + LIBS=$old_LIBS ]) ]) From 16e218a596f3c7fbd5fc246872c436831bdd3451 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 8 Sep 2024 21:09:48 +0200 Subject: [PATCH 20/24] Autotools: Obsolete PHP_TEST_BUILD, PHP_BUILD_THREAD_SAFE, and PHP_DEF_HAVE (#15802) The PHP_BUILD_THREAD_SAFE macro is a simple wrapper around setting the enable_zts variable and can't be used in PHP extensions realistically. The PHP_TEST_BUILD macro might produce warnings on certain compiler configurations and default AC_* macros like AC_LINK_IFELSE, AC_CHECK_LIB, or AC_CHECK_FUNC are better suited for such checks. Also, a quick browse through the open-source PHP extensions doesn't find usages of this macro except in imap extension where patch is was already sent: https://github.com/php/pecl-mail-imap/pull/11 PHP_DEF_HAVE is a wrapper around AC_DEFINE and using AC_DEFINE_UNQUOTED and AS_TR_CPP are better suited for this task where also help text can be passed. Usages in the open source PHP extensions have been checked and patches sent where found. --- UPGRADING.INTERNALS | 3 +++ build/php.m4 | 11 ++++++++--- sapi/apache2handler/config.m4 | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 36bc61d194123..55dcc9033e21e 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -192,6 +192,9 @@ PHP 8.4 INTERNALS UPGRADE NOTES - Autoconf macro PHP_AP_EXTRACT_VERSION is obsolete (use the 'apxs -q HTTPD_VERSION'). - Autoconf macro PHP_OUTPUT is obsolete (use AC_CONFIG_FILES). + - Autoconf macro PHP_TEST_BUILD is obsolete (use AC_* macros). + - Autoconf macro PHP_BUILD_THREAD_SAFE is obsolete (set enable_zts manually). + - Autoconf macro PHP_DEF_HAVE is obsolete (use AC_DEFINE). - Autoconf macro PHP_PROG_SETUP now accepts an argument to set the minimum required PHP version during the build. - Autoconf macro PHP_INSTALL_HEADERS arguments can now be also diff --git a/build/php.m4 b/build/php.m4 index 75c3a046c7b5c..176d4d414476f 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -31,7 +31,9 @@ dnl PHP_DEF_HAVE(what) dnl dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'. dnl -AC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])]) +AC_DEFUN([PHP_DEF_HAVE], [m4_warn([obsolete], + [The macro 'PHP_DEF_HAVE' is obsolete. Use AC_DEFINE.]) +AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])]) dnl dnl PHP_RUN_ONCE(namespace, variable, code) @@ -744,7 +746,9 @@ dnl ---------------------------------------------------------------------------- dnl dnl PHP_BUILD_THREAD_SAFE dnl -AC_DEFUN([PHP_BUILD_THREAD_SAFE], [enable_zts=yes]) +AC_DEFUN([PHP_BUILD_THREAD_SAFE], [m4_warn([obsolete], + [The macro 'PHP_BUILD_THREAD_SAFE' is obsolete. Set 'enable_zts' manually.]) + enable_zts=yes]) dnl dnl PHP_REQUIRE_CXX @@ -1510,7 +1514,8 @@ dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, ext dnl dnl This macro checks whether build works and given function exists. dnl -AC_DEFUN([PHP_TEST_BUILD], [ +AC_DEFUN([PHP_TEST_BUILD], [m4_warn([obsolete], + [The macro 'PHP_TEST_BUILD' is obsolete. Use AC_* macros.]) old_LIBS=$LIBS LIBS="$4 $LIBS" AC_LINK_IFELSE([AC_LANG_SOURCE([ diff --git a/sapi/apache2handler/config.m4 b/sapi/apache2handler/config.m4 index f9231aa9a3d97..e335721f19e98 100644 --- a/sapi/apache2handler/config.m4 +++ b/sapi/apache2handler/config.m4 @@ -122,7 +122,7 @@ if test "$PHP_APXS2" != "no"; then AS_IF([$APXS_HTTPD -V 2>/dev/null | grep 'threaded:.*yes' >/dev/null 2>&1], [ APACHE_THREADED_MPM=yes - PHP_BUILD_THREAD_SAFE + enable_zts=yes ], [APACHE_THREADED_MPM=no]) AC_CONFIG_COMMANDS([apache2handler], [AS_VAR_IF([enable_zts], [yes],, From 08e0729c57755f0cafda04dc0e637fa20db78ebe Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Sun, 8 Sep 2024 18:46:14 +0200 Subject: [PATCH 21/24] Fix uninitialized lineno in constant AST of internal enums Closes GH-15806 --- NEWS | 1 + Zend/zend_enum.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 1948d5fe8bafe..603d71ff855b7 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ PHP NEWS . Fixed bug GH-15587 (CRC32 API build error on arm 32-bit). (Bernd Kuhls, Thomas Petazzoni) . Fixed bug GH-15330 (Do not scan generator frames more than once). (Arnaud) + . Fixed uninitialized lineno in constant AST of internal enums. (ilutov) - Curl: . FIxed bug GH-15547 (curl_multi_select overflow on timeout argument). diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index 85d015b19b77b..9118c620ca445 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -534,12 +534,14 @@ static zend_ast_ref *create_enum_case_ast( ast->child[0]->attr = 0; ZEND_ASSERT(ZSTR_IS_INTERNED(class_name)); ZVAL_STR(zend_ast_get_zval(ast->child[0]), class_name); + Z_LINENO_P(zend_ast_get_zval(ast->child[0])) = 0; ast->child[1] = (zend_ast *) p; p += sizeof(zend_ast_zval); ast->child[1]->kind = ZEND_AST_ZVAL; ast->child[1]->attr = 0; ZEND_ASSERT(ZSTR_IS_INTERNED(case_name)); ZVAL_STR(zend_ast_get_zval(ast->child[1]), case_name); + Z_LINENO_P(zend_ast_get_zval(ast->child[1])) = 0; if (value) { ast->child[2] = (zend_ast *) p; p += sizeof(zend_ast_zval); @@ -547,6 +549,7 @@ static zend_ast_ref *create_enum_case_ast( ast->child[2]->attr = 0; ZEND_ASSERT(!Z_REFCOUNTED_P(value)); ZVAL_COPY_VALUE(zend_ast_get_zval(ast->child[2]), value); + Z_LINENO_P(zend_ast_get_zval(ast->child[2])) = 0; } else { ast->child[2] = NULL; } From 4c11168f602b4d81de9b797af8470abe0e75da4e Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 9 Sep 2024 09:28:57 +0300 Subject: [PATCH 22/24] Fix GH-15656: php8.4beta4 JIT erronous results (#15732) * Improve trace SSA construction and type inference * Fix incorrect abstract stack maintenance * Add missing register store * Avoid IR binding for the dangerous case * Fix access to possibly uninitilezed variable * Improve trace SSA construction and type inference * Fix IR constuction Force load values into regesters before any branches to guarantee SSA dominance property --- ext/opcache/jit/zend_jit_ir.c | 27 ++++++++++++ ext/opcache/jit/zend_jit_trace.c | 75 ++++++++++++++++++++++++++++---- 2 files changed, 93 insertions(+), 9 deletions(-) diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 848c3308b3a51..b24b61748456e 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -1289,6 +1289,16 @@ static bool zend_jit_spilling_may_cause_conflict(zend_jit_ctx *jit, int var, ir_ // } if (jit->ssa->vars[var].var < jit->current_op_array->last_var) { /* IS_CV */ + if (jit->ctx.ir_base[val].op == IR_LOAD + && jit->ctx.ir_base[jit->ctx.ir_base[val].op2].op == IR_ADD + && jit->ctx.ir_base[jit->ctx.ir_base[jit->ctx.ir_base[val].op2].op1].op == IR_RLOAD + && jit->ctx.ir_base[jit->ctx.ir_base[jit->ctx.ir_base[val].op2].op1].op2 == ZREG_FP + && IR_IS_CONST_REF(jit->ctx.ir_base[jit->ctx.ir_base[val].op2].op2) + && jit->ctx.ir_base[jit->ctx.ir_base[jit->ctx.ir_base[val].op2].op2].val.addr != (uintptr_t)EX_NUM_TO_VAR(jit->ssa->vars[var].var) + && EX_VAR_TO_NUM(jit->ctx.ir_base[jit->ctx.ir_base[jit->ctx.ir_base[val].op2].op2].val.addr) < jit->current_op_array->last_var) { + /* binding between different CVs may cause spill conflict */ + return 1; + } return 0; } return 1; @@ -5563,6 +5573,19 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit, ir_refs_init(res_inputs, 2); + if (Z_MODE(op1_addr) == IS_REG + && Z_LOAD(op1_addr) + && jit->ra[Z_SSA_VAR(op1_addr)].ref == IR_NULL) { + /* Force load */ + zend_jit_use_reg(jit, op1_addr); + } + if (Z_MODE(op2_addr) == IS_REG + && Z_LOAD(op2_addr) + && jit->ra[Z_SSA_VAR(op2_addr)].ref == IR_NULL) { + /* Force load */ + zend_jit_use_reg(jit, op2_addr); + } + if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG)) { if_long1 = jit_if_Z_TYPE(jit, op1_addr, IS_LONG); ir_IF_TRUE(if_long1); @@ -6090,6 +6113,10 @@ static int zend_jit_assign_op(zend_jit_ctx *jit, ZEND_UNREACHABLE(); } + if (!zend_jit_store_var_if_necessary_ex(jit, opline->op1.var, op1_def_addr, op1_def_info, op1_addr, op1_info)) { + return 0; + } + if (op1_info & MAY_BE_REF) { ir_MERGE_WITH(slow_path); } diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 69187ca3814ee..79c89c80b8212 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -805,7 +805,12 @@ static bool zend_jit_trace_is_false_loop(const zend_op_array *op_array, const ze } } -static int zend_jit_trace_copy_ssa_var_info(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op **tssa_opcodes, zend_ssa *tssa, int ssa_var) +static int zend_jit_trace_copy_ssa_var_info(const zend_op_array *op_array, + const zend_ssa *ssa, + const zend_op **tssa_opcodes, + zend_ssa *tssa, + int ssa_var, + const zend_op *opline) { int var, use, def, src; zend_ssa_op *op; @@ -913,6 +918,54 @@ static int zend_jit_trace_copy_ssa_var_info(const zend_op_array *op_array, const assert(0); return 0; } + if (opline) { + /* Try to find a difinition in SSA dominators tree */ + var = tssa->vars[ssa_var].var; + uint32_t op_num = opline - op_array->opcodes; + uint32_t b = ssa->cfg.map[op_num]; + zend_basic_block *bb = ssa->cfg.blocks + b; + zend_ssa_phi *pi, *phi; + + while (1) { + while (op_num > bb->start) { + op_num--; + op = ssa->ops + op_num; + if (op->result_def >= 0 && ssa->vars[op->result_def].var == var) { + src = op->result_def; + goto copy_info; + } else if (op->op2_def >= 0 && ssa->vars[op->op2_def].var == var) { + src = op->op2_def; + goto copy_info; + } else if (op->op1_def >= 0 && ssa->vars[op->op1_def].var == var) { + src = op->op1_def; + goto copy_info; + } + } + phi = ssa->blocks[b].phis; + pi = NULL; + while (phi) { + if (ssa->vars[phi->ssa_var].var == var) { + if (phi->pi >= 0) { + pi = phi; + } else { + src = phi->ssa_var; + goto copy_info; + } + } + phi = phi->next; + } + if (pi) { + src = pi->ssa_var; + goto copy_info; + } + if (bb->idom < 0) { + break; + } + b = bb->idom; + bb = ssa->cfg.blocks + b; + op_num = bb->start + bb->len; + } + } goto copy_info; } return 0; @@ -1586,6 +1639,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin /* 4. Type inference */ op_array = trace_buffer->op_array; + opline = trace_buffer[1].opline; jit_extension = (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array); ssa = &jit_extension->func_info.ssa; @@ -1597,7 +1651,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin while (i < op_array->last_var) { if (i < op_array->num_args) { if (ssa->var_info - && zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, i)) { + && zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, i, NULL)) { /* pass */ } else { if (ssa->vars) { @@ -1652,7 +1706,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin } while (i < op_array->last_var + op_array->T) { if (!ssa->var_info - || !zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, i)) { + || !zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, i, opline)) { if (ssa->vars && i < ssa->vars_count) { ssa_vars[i].alias = ssa->vars[i].alias; } else { @@ -1690,7 +1744,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin while (phi) { if (!ssa->var_info - || !zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, phi->ssa_var)) { + || !zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, phi->ssa_var, NULL)) { ssa_vars[phi->ssa_var].alias = ssa_vars[phi->sources[0]].alias; ssa_var_info[phi->ssa_var].type = ssa_var_info[phi->sources[0]].type; } @@ -2409,7 +2463,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin ssa_vars[v].var = i; if (i < op_array->num_args) { if (ssa->var_info - && zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, v)) { + && zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, v, NULL)) { /* pass */ } else { ssa_vars[v].alias = zend_jit_var_may_alias(op_array, ssa, i); @@ -2460,7 +2514,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin while (i < op_array->last_var) { ssa_vars[v].var = i; if (!ssa->var_info - || !zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, v)) { + || !zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, v, NULL)) { ssa_var_info[v].type = MAY_BE_UNDEF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF; } i++; @@ -2469,7 +2523,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin while (i < op_array->last_var + op_array->T) { ssa_vars[v].var = i; if (!ssa->var_info - || !zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, v)) { + || !zend_jit_trace_copy_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, v, NULL)) { ssa_var_info[v].type = MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF; } i++; @@ -3308,6 +3362,7 @@ static void zend_jit_trace_cleanup_stack(zend_jit_ctx *jit, zend_jit_trace_stack CLEAR_STACK_REF(stack, EX_VAR_TO_NUM(opline->op1.var)); } if (ssa_op->op2_use >= 0 + && ssa_op->op2_use != ssa_op->op1_use && jit->ra[ssa_op->op2_use].ref && (jit->ra[ssa_op->op2_use].flags & ZREG_LAST_USE) && (ssa_op->op2_use_chain == -1 @@ -3315,6 +3370,8 @@ static void zend_jit_trace_cleanup_stack(zend_jit_ctx *jit, zend_jit_trace_stack CLEAR_STACK_REF(stack, EX_VAR_TO_NUM(opline->op2.var)); } if (ssa_op->result_use >= 0 + && ssa_op->result_use != ssa_op->op1_use + && ssa_op->result_use != ssa_op->op2_use && jit->ra[ssa_op->result_use].ref && (jit->ra[ssa_op->result_use].flags & ZREG_LAST_USE) && (ssa_op->res_use_chain == -1 @@ -4143,8 +4200,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } else if (i < parent_vars_count && STACK_TYPE(parent_stack, i) != IS_UNKNOWN) { /* This must be already handled by trace type inference */ - ZEND_UNREACHABLE(); - // SET_STACK_TYPE(stack, i, STACK_TYPE(parent_stack, i)); + ZEND_ASSERT(ssa->vars[i].use_chain < 0 && !ssa->vars[i].phi_use_chain); + SET_STACK_TYPE(stack, i, STACK_TYPE(parent_stack, i), 1); } else if ((info & MAY_BE_GUARD) != 0 && (trace_buffer->stop == ZEND_JIT_TRACE_STOP_LOOP || trace_buffer->stop == ZEND_JIT_TRACE_STOP_RECURSIVE_CALL From bca5f6e74f75c17b0a309d2b4efbe7c2f72b119a Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Mon, 9 Sep 2024 09:55:52 +0300 Subject: [PATCH 23/24] Fix OPcache tests under specific conditions --- ext/opcache/tests/bug78185.phpt | 1 + ext/opcache/tests/gh9164.phpt | 1 + ext/opcache/tests/opcache_invalidate_deleted_file.phpt | 1 + 3 files changed, 3 insertions(+) diff --git a/ext/opcache/tests/bug78185.phpt b/ext/opcache/tests/bug78185.phpt index 224c55675c8cf..d8f2b00977ec0 100644 --- a/ext/opcache/tests/bug78185.phpt +++ b/ext/opcache/tests/bug78185.phpt @@ -1,6 +1,7 @@ --TEST-- Bug #78185: file cache only no longer works --INI-- +opcache.enable=1 opcache.enable_cli=1 opcache.optimization_level=-1 opcache.file_cache={PWD} diff --git a/ext/opcache/tests/gh9164.phpt b/ext/opcache/tests/gh9164.phpt index c401639d3314e..5fb36c7958606 100644 --- a/ext/opcache/tests/gh9164.phpt +++ b/ext/opcache/tests/gh9164.phpt @@ -4,6 +4,7 @@ Bug GH-9164: Segfault in zend_accel_class_hash_copy opcache pcntl --INI-- +opcache.enable=1 opcache.enable_cli=1 --FILE-- Date: Mon, 9 Sep 2024 10:00:25 +0300 Subject: [PATCH 24/24] Fix OPcache tests under specific conditions --- ext/opcache/tests/gh9259_003.phpt | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/opcache/tests/gh9259_003.phpt b/ext/opcache/tests/gh9259_003.phpt index 1666f93257ecf..3bdb3d030f2cc 100644 --- a/ext/opcache/tests/gh9259_003.phpt +++ b/ext/opcache/tests/gh9259_003.phpt @@ -8,6 +8,7 @@ if (getenv('SKIP_ASAN')) die('xfail Leaks memory with ASAN'); ?> --INI-- opcache.interned_strings_buffer=500 +opcache.enable=1 opcache.enable_cli=1 --FILE--