diff --git a/Zend/tests/traits/bugs/gh13177.phpt b/Zend/tests/traits/bugs/gh13177.phpt index 42ef0ae9d60d7..465a9b4a40c57 100644 --- a/Zend/tests/traits/bugs/gh13177.phpt +++ b/Zend/tests/traits/bugs/gh13177.phpt @@ -1,5 +1,16 @@ --TEST-- GH-13177 (PHP 8.3.2: final private constructor not allowed when used in trait) +--SKIPIF-- + --FILE-- +--EXPECT-- +string(77) "75877646180287003845291692588996321992008024509271171205840397374930023621264" +string(116) "20901178542000013443295783507452967008255111311111391381095411786512605029527130998551663048238767676593252458334912" +string(155) "11214254709783046066761897074581165564696209875788503860615296581570239055173596662994580613114615553617959320367624022951770022252133452732995602203876100" +string(232) "1187560172240926986956555551805946700914014146395850601682624192167183140821546786142042010581624015945796617035803644080855311724420346850512769661608026325318823192181186500090109111010574371273491473985103578154963883352347509000" +string(230) "41175244239511227932271803271789465275501438128816738161335879819867157609061333189838579416997011220296835767015204168726569753974321567200401024149587401209307771709029048946370759582286096704404540466667318675170269947865547236" +string(345) "264213056979683026715444213001489498112251992104549535125497320782388835160296854596249682279610208850530256165562505337646325742090947380083481042994421218556776724906795900034870043631716997303728488772811762108912277655229349137086580494553471889656657230883768271890897138746582039089128053875620299138149315547875444447674573987934196165016" +string(313) "3168892355445512933444812965909472020409957119791476182178991646344151155563236535370283312345943041041662641584330401473731788344553589640556705580180081371688996848117690101021660395072221488243400947129794119144961728431002781350889740682623487619845390287149216977767858293453242551076767446272230208078076521" +string(469) "5641066640108537808257411937508162073054596465771071759059984994432846497317882144255197676537588304873835452821393566559424565939427398239568910381599042586683472720047480341060077571873252225062218300704671408283921205864218742798766467986541832811143938893251282757214673131758780892167922492222473153470483402146144945253685265421614344082690235633775622262137908096304889066587289890823326962594240368957840634699139830536223598719285051876381571976198029149478069" diff --git a/ext/gmp/tests/gmp_cryptography_ffc.phpt b/ext/gmp/tests/gmp_cryptography_ffc.phpt new file mode 100644 index 0000000000000..f869f055a4329 --- /dev/null +++ b/ext/gmp/tests/gmp_cryptography_ffc.phpt @@ -0,0 +1,108 @@ +--TEST-- +Examples of the usage of gmp for finite field cryptography. +--DESCRIPTION-- +This executes basic operations (addition, multiplication, inverse, exponentiation) as the "base operations". +Then, it performs a primality check, and finally diffie-hellman as the "application". +All operations are done in the 4096-bit MODP Group from RFC 3526: https://www.ietf.org/rfc/rfc3526.txt + +Omitted are calculations on elliptic curves, which are also common, because of the complexity of these algorithms. +Elliptic curves generally operate on smaller values, so their use-case is somewhat covered here, +but curve calculations may need additional operations not used here. + +Further, omitted is explicit demonstration of (public-key) encryption, commitments, zero-knowledge proofs or similar common applications. +However, the operation used in the diffie-hellman is at the core of all these other applications, hence these use-cases are implicitly covered, too. + +$a, $b, and $c generated with +$random = gmp_random_range(0, $prime); +$randomHex = strtoupper(gmp_strval($random, 16)); +echo chunk_split(chunk_split($randomHex, 8, " "), 54); +--EXTENSIONS-- +gmp +--FILE-- + 0); + +// diffie-hellman key exchange (g^a)^b = (g^b)^a +$generator = gmp_init(2); +$factorA = gmp_random_range(1, $primeP); +$factorB = gmp_random_range(1, $primeP); +$left = gmp_powm(gmp_powm($generator, $factorA, $primeP), $factorB, $primeP); +$right = gmp_powm(gmp_powm($generator, $factorB, $primeP), $factorA, $primeP); +var_dump(gmp_cmp($left, $right) === 0); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 23380bfe3d738..6eb5d4c7b4e5a 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -8653,24 +8653,47 @@ static int zend_jit_push_call_frame(zend_jit_ctx *jit, const zend_op *opline, co return 1; } +static int zend_jit_func_guard(zend_jit_ctx *jit, ir_ref func_ref, const zend_function *func, const void *exit_addr) +{ + if (func->type == ZEND_USER_FUNCTION && + (!(func->common.fn_flags & ZEND_ACC_IMMUTABLE) || + (func->common.fn_flags & ZEND_ACC_CLOSURE) || + !func->common.function_name)) { + const zend_op *opcodes = func->op_array.opcodes; + + // JIT: if (call->func.op_array.opcodes != opcodes) goto exit_addr; + ir_GUARD( + ir_EQ( + ir_LOAD_A(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, opcodes))), + ir_CONST_ADDR(opcodes)), + ir_CONST_ADDR(exit_addr)); +#ifdef ZEND_WIN32 + } else if (func->type == ZEND_INTERNAL_FUNCTION) { + // ASLR may cause different addresses in different workers. Check for the internal function handler. + // JIT: if (call->func.internal_function.handler != handler) goto exit_addr; + ir_GUARD( + ir_EQ( + ir_LOAD_A(ir_ADD_OFFSET(func_ref, offsetof(zend_internal_function, handler))), + ir_CONST_FC_FUNC(func->internal_function.handler)), + ir_CONST_ADDR(exit_addr)); +#endif + } else { + // JIT: if (call->func != func) goto exit_addr; + ir_GUARD(ir_EQ(func_ref, ir_CONST_ADDR(func)), ir_CONST_ADDR(exit_addr)); + } + + return 1; +} + static int zend_jit_init_fcall_guard(zend_jit_ctx *jit, uint32_t level, const zend_function *func, const zend_op *to_opline) { int32_t exit_point; const void *exit_addr; ir_ref call; - if (func->type == ZEND_INTERNAL_FUNCTION) { -#ifdef ZEND_WIN32 - // TODO: ASLR may cause different addresses in different workers ??? - return 0; -#endif - } else if (func->type == ZEND_USER_FUNCTION) { - if (!zend_accel_in_shm(func->op_array.opcodes)) { - /* op_array and op_array->opcodes are not persistent. We can't link. */ - return 0; - } - } else { - ZEND_UNREACHABLE(); + if (func->type == ZEND_USER_FUNCTION + && !zend_accel_in_shm(func->op_array.opcodes)) { + /* op_array and op_array->opcodes are not persistent. We can't link. */ return 0; } @@ -8688,24 +8711,7 @@ static int zend_jit_init_fcall_guard(zend_jit_ctx *jit, uint32_t level, const ze level--; } - if (func->type == ZEND_USER_FUNCTION && - (!(func->common.fn_flags & ZEND_ACC_IMMUTABLE) || - (func->common.fn_flags & ZEND_ACC_CLOSURE) || - !func->common.function_name)) { - const zend_op *opcodes = func->op_array.opcodes; - - // JIT: if (call->func.op_array.opcodes != opcodes) goto exit_addr; - ir_GUARD( - ir_EQ( - ir_LOAD_A(ir_ADD_OFFSET(ir_LOAD_A(jit_CALL(call, func)), offsetof(zend_op_array, opcodes))), - ir_CONST_ADDR(opcodes)), - ir_CONST_ADDR(exit_addr)); - } else { - // JIT: if (call->func != func) goto exit_addr; - ir_GUARD(ir_EQ(ir_LOAD_A(jit_CALL(call, func)), ir_CONST_ADDR(func)), ir_CONST_ADDR(exit_addr)); - } - - return 1; + return zend_jit_func_guard(jit, ir_LOAD_A(jit_CALL(call, func)), func, exit_addr); } static int zend_jit_init_fcall(zend_jit_ctx *jit, const zend_op *opline, uint32_t b, const zend_op_array *op_array, zend_ssa *ssa, const zend_ssa_op *ssa_op, int call_level, zend_jit_trace_rec *trace, int checked_stack) @@ -8812,17 +8818,8 @@ static int zend_jit_init_fcall(zend_jit_ctx *jit, const zend_op *opline, uint32_ } if (!func || opline->opcode == ZEND_INIT_FCALL) { ir_GUARD(ref, ir_CONST_ADDR(exit_addr)); - } else if (func->type == ZEND_USER_FUNCTION - && !(func->common.fn_flags & ZEND_ACC_IMMUTABLE)) { - const zend_op *opcodes = func->op_array.opcodes; - - ir_GUARD( - ir_EQ( - ir_LOAD_A(ir_ADD_OFFSET(ref, offsetof(zend_op_array, opcodes))), - ir_CONST_ADDR(opcodes)), - ir_CONST_ADDR(exit_addr)); - } else { - ir_GUARD(ir_EQ(ref, ir_CONST_ADDR(func)), ir_CONST_ADDR(exit_addr)); + } else if (!zend_jit_func_guard(jit, ref, func, exit_addr)) { + return 0; } } else { jit_SET_EX_OPLINE(jit, opline); @@ -9028,11 +9025,7 @@ static int zend_jit_init_method_call(zend_jit_ctx *jit, if ((!func || zend_jit_may_be_modified(func, op_array)) && trace && trace->op == ZEND_JIT_TRACE_INIT_CALL - && trace->func -#ifdef _WIN32 - && trace->func->type != ZEND_INTERNAL_FUNCTION -#endif - ) { + && trace->func) { int32_t exit_point; const void *exit_addr; @@ -9047,19 +9040,8 @@ static int zend_jit_init_method_call(zend_jit_ctx *jit, func = (zend_function*)trace->func; - if (func->type == ZEND_USER_FUNCTION && - (!(func->common.fn_flags & ZEND_ACC_IMMUTABLE) || - (func->common.fn_flags & ZEND_ACC_CLOSURE) || - !func->common.function_name)) { - const zend_op *opcodes = func->op_array.opcodes; - - ir_GUARD( - ir_EQ( - ir_LOAD_A(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, opcodes))), - ir_CONST_ADDR(opcodes)), - ir_CONST_ADDR(exit_addr)); - } else { - ir_GUARD(ir_EQ(func_ref, ir_CONST_ADDR(func)), ir_CONST_ADDR(exit_addr)); + if (!zend_jit_func_guard(jit, func_ref, func, exit_addr)) { + return 0; } } @@ -9213,11 +9195,7 @@ static int zend_jit_init_static_method_call(zend_jit_ctx *jit, if ((!func || zend_jit_may_be_modified(func, op_array)) && trace && trace->op == ZEND_JIT_TRACE_INIT_CALL - && trace->func -#ifdef _WIN32 - && trace->func->type != ZEND_INTERNAL_FUNCTION -#endif - ) { + && trace->func) { int32_t exit_point; const void *exit_addr; @@ -9232,19 +9210,8 @@ static int zend_jit_init_static_method_call(zend_jit_ctx *jit, func = (zend_function*)trace->func; - if (func->type == ZEND_USER_FUNCTION && - (!(func->common.fn_flags & ZEND_ACC_IMMUTABLE) || - (func->common.fn_flags & ZEND_ACC_CLOSURE) || - !func->common.function_name)) { - const zend_op *opcodes = func->op_array.opcodes; - - ir_GUARD( - ir_EQ( - ir_LOAD_A(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, opcodes))), - ir_CONST_ADDR(opcodes)), - ir_CONST_ADDR(exit_addr)); - } else { - ir_GUARD(ir_EQ(func_ref, ir_CONST_ADDR(func)), ir_CONST_ADDR(exit_addr)); + if (!zend_jit_func_guard(jit, func_ref, func, exit_addr)) { + return 0; } } diff --git a/ext/opcache/tests/jit/gh9011.phpt b/ext/opcache/tests/jit/gh9011.phpt new file mode 100644 index 0000000000000..3ffefe2ce29be --- /dev/null +++ b/ext/opcache/tests/jit/gh9011.phpt @@ -0,0 +1,27 @@ +--TEST-- +GH-9011: Assertion failure with tracing JIT +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +--FILE-- +__toString(); + } +} +?> +DONE +--EXPECT-- +DONE \ No newline at end of file diff --git a/win32/build/mkdist.php b/win32/build/mkdist.php index 53a8bb0311db5..11f1690790691 100644 --- a/win32/build/mkdist.php +++ b/win32/build/mkdist.php @@ -62,10 +62,13 @@ function get_depends($module) 'msvcr90.dll', 'wldap32.dll', 'vcruntime140.dll', + 'vcruntime140_1.dll', 'msvcp140.dll', ); static $no_dist_re = array( "api-ms-win-crt-.+\.dll", + "api-ms-win-core-.+\.dll", + "clang_rt.asan_dynamic-.+\.dll", ); global $build_dir, $extra_dll_deps, $ext_targets, $sapi_targets, $pecl_targets, $phpdll, $per_module_deps, $pecl_dll_deps;