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/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 85a45a866c711..55dcc9033e21e 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,50 @@ 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_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 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. + - 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 PGSQL_LIBS environment variables. When a directory argument is provided to @@ -218,6 +230,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/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/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_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 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 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-- 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..8676d1166cf3a 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)) { @@ -544,12 +548,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); @@ -557,6 +563,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; } 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/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/build/php.m4 b/build/php.m4 index aa8057fa5ff52..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) @@ -467,21 +469,20 @@ AC_DEFUN([PHP_UTILIZE_RPATHS],[ ]) dnl -dnl PHP_ADD_INCLUDE(path [,before]) +dnl PHP_ADD_INCLUDE(paths [,prepend]) dnl -dnl Add an include path. If before is 1, add in the beginning of INCLUDES. +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],[ - 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 +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 @@ -745,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 @@ -1137,8 +1140,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 +1158,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 +1169,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 +1188,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 @@ -1523,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([ @@ -2043,7 +2035,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/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 {} diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index 08f6b7c14cb90..b7fef270c93d3 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); @@ -188,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; @@ -238,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; @@ -288,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; @@ -338,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; @@ -393,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; @@ -449,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; @@ -526,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; @@ -588,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; @@ -633,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; @@ -774,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(); } @@ -1305,15 +1304,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, bool scale_is_null, uint32_t arg_num) -{ - if (UNEXPECTED(!scale_is_null && (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; @@ -1359,7 +1349,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 +1459,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 +1520,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 +1574,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; } 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/gd/config.m4 b/ext/gd/config.m4 index d1d727b130c48..7da5b8cd1b2ec 100644 --- a/ext/gd/config.m4 +++ b/ext/gd/config.m4 @@ -279,17 +279,25 @@ 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/]) - 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/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/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 <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; @@ -4534,8 +4544,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)); @@ -5559,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); @@ -6086,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 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-- --INI-- opcache.interned_strings_buffer=500 +opcache.enable=1 opcache.enable_cli=1 --FILE-- = 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) 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/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(); 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/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) \ diff --git a/sapi/apache2handler/config.m4 b/sapi/apache2handler/config.m4 index b5f1aed2e14e0..e335721f19e98 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) @@ -112,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],, 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); } 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]);