Skip to content

Commit 818f6d5

Browse files
committed
Ah there's the bug
1 parent 343272e commit 818f6d5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Zend/zend.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{
735735
compiler_globals->map_ptr_base = ZEND_MAP_PTR_BIASED_BASE(NULL);
736736
compiler_globals->map_ptr_size = 0;
737737
compiler_globals->map_ptr_last = global_map_ptr_last;
738+
compiler_globals->internal_run_time_cache = 0;
738739
if (compiler_globals->map_ptr_last) {
739740
/* Allocate map_ptr table */
740741
compiler_globals->map_ptr_size = ZEND_MM_ALIGNED_SIZE_EX(compiler_globals->map_ptr_last, 4096);
@@ -2028,11 +2029,11 @@ ZEND_API void *zend_map_ptr_new_static(void)
20282029
zend_map_ptr_static_size += 4096;
20292030
/* Grow map_ptr table */
20302031
CG(map_ptr_size) = ZEND_MM_ALIGNED_SIZE_EX(CG(map_ptr_last), 4096);
2031-
/* Note: there are no used non-static map_ptrs yet, hence we don't need to move the whole thing */
20322032
CG(map_ptr_real_base) = perealloc(CG(map_ptr_real_base), CG(map_ptr_size) * sizeof(void*), 1);
2033+
memmove((char*)CG(map_ptr_real_base) + 4096 * sizeof(void *), CG(map_ptr_real_base), (CG(map_ptr_last) - 4096) * sizeof(void *));
20332034
CG(map_ptr_base) = ZEND_MAP_PTR_BIASED_BASE(CG(map_ptr_real_base));
20342035
}
2035-
ptr = (void**)CG(map_ptr_real_base) + zend_map_ptr_static_last;
2036+
ptr = (void**)CG(map_ptr_real_base) + (zend_map_ptr_static_last & 4095);
20362037
*ptr = NULL;
20372038
zend_map_ptr_static_last++;
20382039
return ZEND_MAP_PTR_PTR2OFFSET(ptr);

Zend/zend_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
839839
#define ZSTR_GET_CE_CACHE(s) ZSTR_GET_CE_CACHE_EX(s, 1)
840840
#define ZSTR_SET_CE_CACHE(s, ce) ZSTR_SET_CE_CACHE_EX(s, ce, 1)
841841

842-
#define ZSTR_VALID_CE_CACHE(s) EXPECTED((GC_REFCOUNT(s)-1)/sizeof(void *) < CG(map_ptr_last))
842+
#define ZSTR_VALID_CE_CACHE(s) EXPECTED((GC_REFCOUNT(s)-1)/sizeof(void *) < CG(map_ptr_last) - zend_map_ptr_static_size)
843843

844844
#define ZSTR_GET_CE_CACHE_EX(s, validate) \
845845
((!(validate) || ZSTR_VALID_CE_CACHE(s)) ? GET_CE_CACHE(GC_REFCOUNT(s)) : NULL)

0 commit comments

Comments
 (0)