Skip to content

Commit f0ad377

Browse files
committed
Fix zend_mm_chunk.reserve
1 parent 8759ad6 commit f0ad377

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Zend/zend_alloc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,11 @@ struct _zend_mm_chunk {
391391
uint32_t free_tail; /* number of free pages at the end of chunk */
392392
uint32_t num;
393393
/* align heap_slot to cache line boundary (assumed to be 64 bytes) */
394+
#if ZEND_MM_HEAP_PROTECTION
394395
char reserve[64 - (sizeof(void*) * 4 + sizeof(uint32_t) * 3)];
396+
#else
397+
char reserve[64 - (sizeof(void*) * 3 + sizeof(uint32_t) * 3)];
398+
#endif
395399
zend_mm_heap heap_slot; /* used only in main chunk */
396400
#if ZEND_MM_HEAP_PROTECTION
397401
zend_mm_zone *zone;
@@ -400,6 +404,8 @@ struct _zend_mm_chunk {
400404
zend_mm_page_info map[ZEND_MM_PAGES]; /* 2 KB = 512 * 4 */
401405
};
402406

407+
ZEND_STATIC_ASSERT(ZEND_MM_ALIGNED_OFFSET(XtOffsetOf(zend_mm_chunk, heap_slot), 64) == 0,
408+
"zend_mm_chunk.heap_slot should be aligned to cache line boundary");
403409
ZEND_STATIC_ASSERT(sizeof(zend_mm_chunk) <= ZEND_MM_FIRST_PAGE * ZEND_MM_PAGE_SIZE, "");
404410

405411
struct _zend_mm_page {

0 commit comments

Comments
 (0)