Skip to content

Commit

Permalink
Fix bad alignment
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Weinand <[email protected]>
  • Loading branch information
bwoebi committed Feb 17, 2025
1 parent ec35e3a commit 7ce04d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -4364,7 +4364,7 @@ static void preload_load(size_t orig_map_ptr_static_last)
zend_map_ptr_static_last = ZCSG(map_ptr_static_last);

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

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) {
void **ptr = (void **) CG(map_ptr_real_base) + zend_map_ptr_static_size - ((cur_static_map_ptr & ~4095) + 4096) + (cur_static_map_ptr & 4095);
// Note: chunked like: [8192..12287][4096..8191][0..4095]
void **ptr = (void **) CG(map_ptr_real_base) + zend_map_ptr_static_size - ZEND_MM_ALIGNED_SIZE_EX(cur_static_map_ptr + 1, 4096) + (cur_static_map_ptr & 4095);
*ptr = cache;
cache += runtime_cache_size;
}
Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/ZendAccelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ typedef struct _zend_accel_shared_globals {
void *jit_traces;
const void **jit_exit_groups;

size_t map_ptr_static_last;

/* Interned Strings Support (must be the last element) */
ZEND_SET_ALIGNED(ZEND_STRING_TABLE_POS_ALIGNMENT, zend_string_table interned_strings);

size_t map_ptr_static_last;
} zend_accel_shared_globals;

#ifdef ZEND_WIN32
Expand Down

0 comments on commit 7ce04d3

Please sign in to comment.