diff --git a/NEWS b/NEWS index 9ae85310388b2..1467bac7be467 100644 --- a/NEWS +++ b/NEWS @@ -7,14 +7,24 @@ PHP NEWS emits a warning. (Girgias) . Fixed bug GH-19637 (Incorrect Closure scope for FCC in constant expression). (timwolla) + . Fixed bug GH-19613 (Stale array iterator pointer). (ilutov) + +- Date: + . Fixed date_sunrise() and date_sunset() with partial-hour UTC offset. + (ilutov) - EXIF: . Added support to retrieve Exif from HEIF file. (Benstone Zhang) +- FPM: + . Fixed failed debug assertion when php_admin_value setting fails. (ilutov) + - Opcache: . Fixed bug GH-19486 (Incorrect opline after deoptimization). (Arnaud) . Fixed bug GH-19601 (Wrong JIT stack setup on aarch64/clang). (Arnaud) . Fixed bug GH-19388 (Broken opcache.huge_code_pages). (Arnaud) + . Fixed bug GH-19657 (Build fails on non-glibc/musl/freebsd/macos/win + platforms). (Arnaud) - PCRE: . Upgraded to pcre2lib from 10.45 to 10.46. (nielsdos) diff --git a/Zend/tests/gh19613.phpt b/Zend/tests/gh19613.phpt new file mode 100644 index 0000000000000..cd8360b681c79 --- /dev/null +++ b/Zend/tests/gh19613.phpt @@ -0,0 +1,22 @@ +--TEST-- +GH-19613: Invalidated array iterator pointer after array separation +--FILE-- + +--EXPECT-- +===DONE=== diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index f48c298f167e7..d460c40b79714 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -634,8 +634,15 @@ ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos_ex(uint32_t idx, zval && EXPECTED(!HT_ITERATORS_OVERFLOW(ht))) { HT_DEC_ITERATORS_COUNT(iter->ht); } - SEPARATE_ARRAY(array); - ht = Z_ARRVAL_P(array); + + /* Inlined SEPARATE_ARRAY() with updating of iterator when EG(ht_iterators) grows. */ + if (UNEXPECTED(GC_REFCOUNT(ht) > 1)) { + ZVAL_ARR(array, zend_array_dup(ht)); + GC_TRY_DELREF(ht); + iter = EG(ht_iterators) + idx; + ht = Z_ARRVAL_P(array); + } + if (EXPECTED(!HT_ITERATORS_OVERFLOW(ht))) { HT_INC_ITERATORS_COUNT(ht); } diff --git a/ext/date/php_date.c b/ext/date/php_date.c index fd4dc05a7ea6c..e69512cedb440 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -5493,7 +5493,7 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, bool calc_s t->zone_type = TIMELIB_ZONETYPE_ID; if (gmt_offset_is_null) { - gmt_offset = timelib_get_current_offset(t) / 3600; + gmt_offset = timelib_get_current_offset(t) / 3600.0; } timelib_unixtime2local(t, time); diff --git a/ext/date/tests/sunfuncts_partial_hour_utc_offset.phpt b/ext/date/tests/sunfuncts_partial_hour_utc_offset.phpt new file mode 100644 index 0000000000000..279e40fa654c3 --- /dev/null +++ b/ext/date/tests/sunfuncts_partial_hour_utc_offset.phpt @@ -0,0 +1,18 @@ +--TEST-- +Incorrect timezone detection in date_sunrise() for partial-hour UTC offsets +--FILE-- +setTimestamp(date_sun_info($timestamp, $longitude, $latitude)['sunrise']); +echo $dt->format('H:i'), "\n"; +?> +--EXPECT-- +06:10 +06:11 diff --git a/ext/opcache/jit/tls/zend_jit_tls_aarch64.c b/ext/opcache/jit/tls/zend_jit_tls_aarch64.c index 2dc82221e9cb1..24f0f88454b63 100644 --- a/ext/opcache/jit/tls/zend_jit_tls_aarch64.c +++ b/ext/opcache/jit/tls/zend_jit_tls_aarch64.c @@ -238,6 +238,7 @@ void *zend_jit_tsrm_ls_cache_address( size_t module_index, size_t module_offset ) { +#ifndef USE_FALLBACK char *thread_pointer; __asm__ __volatile__( "mrs %0, tpidr_el0\n" @@ -251,5 +252,6 @@ void *zend_jit_tsrm_ls_cache_address( dtv_pointer_t *dtv = *(dtv_pointer_t**)((uintptr_t)thread_pointer + DTV_OFFSET); return (void*)(((dtv_pointer_t*)((char*)dtv + module_index))->val + module_offset); } +#endif return NULL; } diff --git a/ext/opcache/jit/tls/zend_jit_tls_x86.c b/ext/opcache/jit/tls/zend_jit_tls_x86.c index bca46c8f82664..4e06bbd1eacde 100644 --- a/ext/opcache/jit/tls/zend_jit_tls_x86.c +++ b/ext/opcache/jit/tls/zend_jit_tls_x86.c @@ -222,6 +222,7 @@ void *zend_jit_tsrm_ls_cache_address( size_t module_index, size_t module_offset ) { +#ifndef USE_FALLBACK char *thread_pointer; __asm__ __volatile__( "movl %%gs:0, %0\n" @@ -235,5 +236,6 @@ void *zend_jit_tsrm_ls_cache_address( dtv_pointer_t *dtv = *(dtv_pointer_t**)((uintptr_t)thread_pointer + DTV_OFFSET); return (void*)(((dtv_pointer_t*)((char*)dtv + module_index))->val + module_offset); } +#endif return NULL; } diff --git a/ext/opcache/jit/tls/zend_jit_tls_x86_64.c b/ext/opcache/jit/tls/zend_jit_tls_x86_64.c index 3adeb1ff8064c..11ffe495fcbb3 100644 --- a/ext/opcache/jit/tls/zend_jit_tls_x86_64.c +++ b/ext/opcache/jit/tls/zend_jit_tls_x86_64.c @@ -205,6 +205,7 @@ void *zend_jit_tsrm_ls_cache_address( size_t module_index, size_t module_offset ) { +#ifndef USE_FALLBACK char *thread_pointer; __asm__ __volatile__( "movq %%fs:0, %0\n" @@ -218,5 +219,6 @@ void *zend_jit_tsrm_ls_cache_address( dtv_pointer_t *dtv = *(dtv_pointer_t**)((uintptr_t)thread_pointer + DTV_OFFSET); return (void*)(((dtv_pointer_t*)((char*)dtv + module_index))->val + module_offset); } +#endif return NULL; } diff --git a/sapi/fpm/fpm/fpm_php.c b/sapi/fpm/fpm/fpm_php.c index 97d35d42bfe66..8deb107d0a389 100644 --- a/sapi/fpm/fpm/fpm_php.c +++ b/sapi/fpm/fpm/fpm_php.c @@ -41,6 +41,8 @@ static int fpm_php_zend_ini_alter_master(char *name, int name_length, char *new_ ini_entry->modifiable = mode; } } else { + /* The string wasn't installed and won't be shared, it's safe to drop. */ + GC_MAKE_PERSISTENT_LOCAL(duplicate); zend_string_release_ex(duplicate, 1); } diff --git a/sapi/fpm/tests/php_admin_value-failure.phpt b/sapi/fpm/tests/php_admin_value-failure.phpt new file mode 100644 index 0000000000000..dcac2e29c72a8 --- /dev/null +++ b/sapi/fpm/tests/php_admin_value-failure.phpt @@ -0,0 +1,48 @@ +--TEST-- +RC violation on failed php_admin_value +--SKIPIF-- + +--FILE-- +setUserIni($ini); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectBody(['string(2) "14"']); +$tester->terminate(); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- + diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index 0a94adf21305a..ccbccc32f711b 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -1206,14 +1206,14 @@ PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num) /* {{{ */ name = estrdup(brake->name); name_len = strlen(name); if (zend_hash_num_elements(&PHPDBG_G(bp)[type]) == 1) { - PHPDBG_G(flags) &= ~(1<<(brake->type+1)); + PHPDBG_G(flags) &= ~(1ull<<(brake->type+1)); } } break; default: { if (zend_hash_num_elements(table) == 1) { - PHPDBG_G(flags) &= ~(1<<(brake->type+1)); + PHPDBG_G(flags) &= ~(1ull<<(brake->type+1)); } } }