Skip to content

Commit 4f8cf6e

Browse files
committed
Fix bad alignment
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
1 parent ec35e3a commit 4f8cf6e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4364,7 +4364,7 @@ static void preload_load(size_t orig_map_ptr_static_last)
43644364
zend_map_ptr_static_last = ZCSG(map_ptr_static_last);
43654365

43664366
/* Grow map_ptr table as needed, but allocate once for static + regular map_ptrs */
4367-
size_t new_static_size = ((zend_map_ptr_static_last - 1) & 4095) + 1;
4367+
size_t new_static_size = ZEND_MM_ALIGNED_SIZE_EX(zend_map_ptr_static_last, 4096);
43684368
if (zend_map_ptr_static_size != new_static_size) {
43694369
void *new_base = pemalloc((new_static_size + CG(map_ptr_size)) * sizeof(void *), 1);
43704370
if (CG(map_ptr_real_base)) {
@@ -4389,7 +4389,8 @@ static void preload_load(size_t orig_map_ptr_static_last)
43894389
ZCG(preloaded_internal_run_time_cache) = cache;
43904390

43914391
for (size_t cur_static_map_ptr = orig_map_ptr_static_last; cur_static_map_ptr < zend_map_ptr_static_last; ++cur_static_map_ptr) {
4392-
void **ptr = (void **) CG(map_ptr_real_base) + zend_map_ptr_static_size - ((cur_static_map_ptr & ~4095) + 4096) + (cur_static_map_ptr & 4095);
4392+
// Note: chunked like: [8192..12287][4096..8191][0..4095]
4393+
void **ptr = (void **) CG(map_ptr_real_base) + zend_map_ptr_static_size - ZEND_MM_ALIGNED_SIZE_EX(cur_static_map_ptr, 4096) + (cur_static_map_ptr & 4095);
43934394
*ptr = cache;
43944395
cache += runtime_cache_size;
43954396
}

ext/opcache/ZendAccelerator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,10 @@ typedef struct _zend_accel_shared_globals {
281281
void *jit_traces;
282282
const void **jit_exit_groups;
283283

284+
size_t map_ptr_static_last;
285+
284286
/* Interned Strings Support (must be the last element) */
285287
ZEND_SET_ALIGNED(ZEND_STRING_TABLE_POS_ALIGNMENT, zend_string_table interned_strings);
286-
287-
size_t map_ptr_static_last;
288288
} zend_accel_shared_globals;
289289

290290
#ifdef ZEND_WIN32

0 commit comments

Comments
 (0)