Skip to content

Commit e3c9f5a

Browse files
authored
Compute the size of pages before allocating memory (#14650)
`start_memory_manager()` calls `zend_mm_init()` via `alloc_globals_ctor()` before setting `REAL_PAGE_SIZE` to the right value. Moving the `REAL_PAGE_SIZE` setting block before the call to `alloc_globals_ctor()` makes the allocator behave properly on systems with a page size different than 4k. Suggested-by: arnaud-lb
1 parent 3da6377 commit e3c9f5a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Zend/zend_alloc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3109,18 +3109,18 @@ static void alloc_globals_dtor(zend_alloc_globals *alloc_globals)
31093109

31103110
ZEND_API void start_memory_manager(void)
31113111
{
3112-
#ifdef ZTS
3113-
ts_allocate_fast_id(&alloc_globals_id, &alloc_globals_offset, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor);
3114-
#else
3115-
alloc_globals_ctor(&alloc_globals);
3116-
#endif
31173112
#ifndef _WIN32
31183113
# if defined(_SC_PAGESIZE)
31193114
REAL_PAGE_SIZE = sysconf(_SC_PAGESIZE);
31203115
# elif defined(_SC_PAGE_SIZE)
31213116
REAL_PAGE_SIZE = sysconf(_SC_PAGE_SIZE);
31223117
# endif
31233118
#endif
3119+
#ifdef ZTS
3120+
ts_allocate_fast_id(&alloc_globals_id, &alloc_globals_offset, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor);
3121+
#else
3122+
alloc_globals_ctor(&alloc_globals);
3123+
#endif
31243124
}
31253125

31263126
ZEND_API zend_mm_heap *zend_mm_set_heap(zend_mm_heap *new_heap)

0 commit comments

Comments
 (0)