@@ -179,14 +179,12 @@ static size_t _real_page_size = ZEND_MM_PAGE_SIZE;
179179# include <sanitizer/asan_interface.h>
180180
181181#define ZEND_ASAN_POISON_MEMORY_REGION (_ptr , _size ) do { \
182- printf("Poisoning memory %p, size %zu %d\n", (_ptr), (_size), __LINE__); \
183182 if (UNEXPECTED(((size_t) (_ptr)) & ((size_t)7))) { \
184183 zend_mm_panic("Wrong alignment"); \
185184 } \
186185 ASAN_POISON_MEMORY_REGION((_ptr), (_size));\
187186} while (0);
188187#define ZEND_ASAN_UNPOISON_MEMORY_REGION (_ptr , _size ) do { \
189- printf("Unpoisoning memory %p, size %zu line %d\n", (_ptr), (_size), __LINE__); \
190188 if (UNEXPECTED(((size_t) (_ptr)) & ((size_t)7))) { \
191189 zend_mm_panic("Wrong alignment"); \
192190 } \
@@ -404,20 +402,20 @@ ZEND_COLD void zend_debug_alloc_output(char *format, ...)
404402 va_list args ;
405403
406404 va_start (args , format );
407- vsprintf (output_buf , format , args );
405+ vs //printf (output_buf, format, args);
408406 va_end (args );
409407
410408#ifdef ZEND_WIN32
411409 OutputDebugString (output_buf );
412410#else
413- fprintf (stderr , "%s" , output_buf );
411+ f //printf (stderr, "%s", output_buf);
414412#endif
415413}
416414#endif
417415
418416static ZEND_COLD ZEND_NORETURN void zend_mm_panic (const char * message )
419417{
420- fprintf (stderr , "%s\n" , message );
418+ f //printf (stderr, "%s\n", message);
421419/* See http://support.microsoft.com/kb/190351 */
422420#ifdef ZEND_WIN32
423421 fflush (stderr );
@@ -461,10 +459,10 @@ static void stderr_last_error(char *msg)
461459 char * buf = php_win32_error_to_msg (err );
462460
463461 if (!buf [0 ]) {
464- fprintf (stderr , "\n%s: [0x%08lx]\n" , msg , err );
462+ f //printf (stderr, "\n%s: [0x%08lx]\n", msg, err);
465463 }
466464 else {
467- fprintf (stderr , "\n%s: [0x%08lx] %s\n" , msg , err , buf );
465+ f //printf (stderr, "\n%s: [0x%08lx] %s\n", msg, err, buf);
468466 }
469467
470468 php_win32_error_msg_free (buf );
@@ -506,7 +504,7 @@ static void zend_mm_munmap(void *addr, size_t size)
506504#else
507505 if (munmap (addr , size ) != 0 ) {
508506#if ZEND_MM_ERROR
509- fprintf (stderr , "\nmunmap() failed: [%d] %s\n" , errno , strerror (errno ));
507+ f //printf (stderr, "\nmunmap() failed: [%d] %s\n", errno, strerror(errno));
510508#endif
511509 }
512510#endif
@@ -542,7 +540,7 @@ static void *zend_mm_mmap_fixed(void *addr, size_t size)
542540
543541 if (ptr == MAP_FAILED ) {
544542#if ZEND_MM_ERROR && !defined(MAP_EXCL ) && !defined(MAP_TRYFIXED )
545- fprintf (stderr , "\nmmap() fixed failed: [%d] %s\n" , errno , strerror (errno ));
543+ f //printf (stderr, "\nmmap() fixed failed: [%d] %s\n", errno, strerror(errno));
546544#endif
547545 return NULL ;
548546 } else if (ptr != addr ) {
@@ -590,7 +588,7 @@ static void *zend_mm_mmap(size_t size)
590588
591589 if (ptr == MAP_FAILED ) {
592590#if ZEND_MM_ERROR
593- fprintf (stderr , "\nmmap() failed: [%d] %s\n" , errno , strerror (errno ));
591+ f //printf (stderr, "\nmmap() failed: [%d] %s\n", errno, strerror(errno));
594592#endif
595593 return NULL ;
596594 }
@@ -1208,7 +1206,7 @@ static zend_never_inline void zend_mm_free_pages(zend_mm_heap *heap, zend_mm_chu
12081206
12091207static zend_always_inline void zend_mm_free_large (zend_mm_heap * heap , zend_mm_chunk * chunk , int page_num , int pages_count )
12101208{
1211- printf ("Freeing large %p\n" , chunk );
1209+ // printf("Freeing large %p\n", chunk);
12121210#if ZEND_MM_STAT
12131211 heap -> size -= pages_count * ZEND_MM_PAGE_SIZE ;
12141212#endif
@@ -1317,7 +1315,7 @@ static zend_always_inline zend_mm_free_slot* zend_mm_decode_free_slot(zend_mm_he
13171315
13181316static zend_always_inline void zend_mm_set_next_free_slot (const char * from , zend_mm_heap * heap , uint32_t bin_num , zend_mm_free_slot * slot , zend_mm_free_slot * next )
13191317{
1320- printf ("set_next_free_slot from %s: slot %p, next: %p, size: %d\n" , from , slot , next , bin_data_size [bin_num ]);
1318+ // printf("set_next_free_slot from %s: slot %p, next: %p, size: %d\n", from, slot, next, bin_data_size[bin_num]);
13211319
13221320 ZEND_MM_ASSERT (bin_data_size [bin_num ] >= ZEND_MM_MIN_USEABLE_BIN_SIZE );
13231321
@@ -1333,7 +1331,7 @@ static zend_always_inline void zend_mm_set_next_free_slot(const char *from, zend
13331331
13341332static zend_always_inline zend_mm_free_slot * zend_mm_get_next_free_slot (zend_mm_heap * heap , uint32_t bin_num , zend_mm_free_slot * slot )
13351333{
1336- printf ("get_next_free_slot: slot %p, size: %d\n" , slot , bin_data_size [bin_num ]);
1334+ // printf("get_next_free_slot: slot %p, size: %d\n", slot, bin_data_size[bin_num]);
13371335
13381336 ZEND_ASAN_UNPOISON_MEMORY_REGION (slot , 8 );
13391337 ZEND_ASAN_UNPOISON_MEMORY_REGION (& ZEND_MM_FREE_SLOT_PTR_SHADOW (slot , bin_num ), 8 );
@@ -1357,7 +1355,7 @@ static zend_always_inline zend_mm_free_slot *zend_mm_get_next_free_slot(zend_mm_
13571355
13581356static zend_never_inline void * zend_mm_alloc_small_slow (zend_mm_heap * heap , uint32_t bin_num ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC )
13591357{
1360- printf ("Alocating small size %d\n" , bin_data_size [bin_num ]);
1358+ // printf("Alocating small size %d\n", bin_data_size[bin_num]);
13611359 zend_mm_chunk * chunk ;
13621360 int page_num ;
13631361 zend_mm_bin * bin ;
@@ -1405,7 +1403,7 @@ static zend_never_inline void *zend_mm_alloc_small_slow(zend_mm_heap *heap, uint
14051403 } while (p != end );
14061404
14071405 zend_mm_set_next_free_slot ("alloc_small" , heap , bin_num , p , NULL );
1408- printf ("poison final: slot %p, size: %d\n" , p , bin_data_size [bin_num ]);
1406+ // printf("poison final: slot %p, size: %d\n", p, bin_data_size[bin_num]);
14091407
14101408#if ZEND_DEBUG
14111409 do {
@@ -1435,7 +1433,7 @@ static zend_always_inline void *zend_mm_alloc_small(zend_mm_heap *heap, int bin_
14351433 zend_mm_free_slot * p = heap -> free_slot [bin_num ];
14361434 heap -> free_slot [bin_num ] = zend_mm_get_next_free_slot (heap , bin_num , p );
14371435
1438- printf ("Returning slot %p, size %d, value %ld\n" , p , bin_data_size [bin_num ], (uint64_t ) p );
1436+ // printf("Returning slot %p, size %d, value %ld\n", p, bin_data_size[bin_num], (uint64_t) p);
14391437 return p ;
14401438 } else {
14411439 return zend_mm_alloc_small_slow (heap , bin_num ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC );
@@ -1444,7 +1442,7 @@ static zend_always_inline void *zend_mm_alloc_small(zend_mm_heap *heap, int bin_
14441442
14451443static zend_always_inline void zend_mm_free_small (zend_mm_heap * heap , void * ptr , int bin_num )
14461444{
1447- printf ("Freeing small size %d, ptr %p\n" , bin_data_size [bin_num ], ptr );
1445+ // printf("Freeing small size %d, ptr %p\n", bin_data_size[bin_num], ptr);
14481446
14491447 ZEND_MM_ASSERT (bin_data_size [bin_num ] >= ZEND_MM_MIN_USEABLE_BIN_SIZE );
14501448
@@ -1545,13 +1543,13 @@ static zend_always_inline void *zend_mm_alloc_heap(zend_mm_heap *heap, size_t si
15451543 ptr = zend_mm_alloc_huge (heap , size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC );
15461544 }
15471545 ZEND_ASAN_UNPOISON_MEMORY_REGION (ptr , size );
1548- printf ("Allocated %zu bytes at %p\n" , size , ptr );
1546+ // printf("Allocated %zu bytes at %p\n", size, ptr);
15491547 return ptr ;
15501548}
15511549
15521550static zend_always_inline void zend_mm_free_heap (zend_mm_heap * heap , void * ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC )
15531551{
1554- printf ("Freeing %p\n" , ptr );
1552+ // printf("Freeing %p\n", ptr);
15551553
15561554 size_t page_offset = ZEND_MM_ALIGNED_OFFSET (ptr , ZEND_MM_CHUNK_SIZE );
15571555
@@ -1735,7 +1733,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
17351733 } else {
17361734 ret = zend_mm_realloc_huge (heap , ptr , size , copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC );
17371735 }
1738- printf ("Reallocated (1) %zu bytes from %p to %p\n" , size , ptr , ret );
1736+ // printf("Reallocated (1) %zu bytes from %p to %p\n", size, ptr, ret);
17391737 return ret ;
17401738 } else {
17411739 zend_mm_chunk * chunk = (zend_mm_chunk * )ZEND_MM_ALIGNED_BASE (ptr , ZEND_MM_CHUNK_SIZE );
@@ -1772,12 +1770,12 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
17721770 ZEND_ASAN_UNPOISON_MEMORY_REGION (ptr , copy_size );
17731771 memcpy (ret , ptr , copy_size );
17741772 zend_mm_free_small (heap , ptr , old_bin_num );
1775- printf ("Reallocated (2, 1) %zu bytes from %p to %p\n" , size , ptr , ret );
1773+ // printf("Reallocated (2, 1) %zu bytes from %p to %p\n", size, ptr, ret);
17761774 } else {
17771775 /* reallocation in-place */
17781776 ret = ptr ;
17791777 ZEND_ASAN_UNPOISON_MEMORY_REGION (ret , size );
1780- printf ("Reallocated (2, 2) %zu bytes from %p to %p\n" , size , ptr , ret );
1778+ // printf("Reallocated (2, 2) %zu bytes from %p to %p\n", size, ptr, ret);
17811779 }
17821780 } else if (size <= ZEND_MM_MAX_SMALL_SIZE ) {
17831781 /* small extension */
@@ -1796,7 +1794,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
17961794 heap -> peak = MAX (orig_peak , heap -> size );
17971795 } while (0 );
17981796#endif
1799- printf ("Reallocated (2, 3) %zu bytes from %p to %p\n" , size , ptr , ret );
1797+ // printf("Reallocated (2, 3) %zu bytes from %p to %p\n", size, ptr, ret);
18001798 } else {
18011799 /* slow reallocation */
18021800 break ;
@@ -1830,7 +1828,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
18301828#endif
18311829 ZEND_ASAN_POISON_CHUNK_HEADER_NOT_HEAP (chunk , heap );
18321830 ZEND_ASAN_UNPOISON_MEMORY_REGION (ptr , size );
1833- printf ("Reallocated (3) %zu => %zu bytes from %p to %p\n" , old_size , size , ptr , ptr );
1831+ // printf("Reallocated (3) %zu => %zu bytes from %p to %p\n", old_size, size, ptr, ptr);
18341832 return ptr ;
18351833 } else if (new_size < old_size ) {
18361834 /* free tail pages */
@@ -1854,7 +1852,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
18541852 dbg -> orig_lineno = __zend_orig_lineno ;
18551853#endif
18561854 ZEND_ASAN_POISON_CHUNK_HEADER_NOT_HEAP (chunk , heap );
1857- printf ("Reallocated (4) %zu bytes from %p to %p\n" , size , ptr , ptr );
1855+ // printf("Reallocated (4) %zu bytes from %p to %p\n", size, ptr, ptr);
18581856 return ptr ;
18591857 } else /* if (new_size > old_size) */ {
18601858 int new_pages_count = (int )(new_size / ZEND_MM_PAGE_SIZE );
@@ -1884,7 +1882,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
18841882 dbg -> orig_lineno = __zend_orig_lineno ;
18851883#endif
18861884 ZEND_ASAN_POISON_CHUNK_HEADER_NOT_HEAP (chunk , heap );
1887- printf ("Reallocated (5) %zu bytes from %p to %p\n" , size , ptr , ptr );
1885+ // printf("Reallocated (5) %zu bytes from %p to %p\n", size, ptr, ptr);
18881886 return ptr ;
18891887 }
18901888 }
@@ -1898,7 +1896,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
18981896
18991897 copy_size = MIN (old_size , copy_size );
19001898 ret = zend_mm_realloc_slow (heap , ptr , size , copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC );
1901- printf ("Reallocated (6) %zu bytes from %p to %p\n" , size , ptr , ret );
1899+ // printf("Reallocated (6) %zu bytes from %p to %p\n", size, ptr, ret);
19021900 return ret ;
19031901}
19041902
@@ -2061,7 +2059,7 @@ static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D
20612059
20622060static void zend_mm_free_huge (zend_mm_heap * heap , void * ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC )
20632061{
2064- printf ("Freeing huge %p\n" , ptr );
2062+ // printf("Freeing huge %p\n", ptr);
20652063
20662064 size_t size ;
20672065
@@ -2099,7 +2097,7 @@ static zend_mm_heap *zend_mm_init(void)
20992097
21002098 if (UNEXPECTED (chunk == NULL )) {
21012099#if ZEND_MM_ERROR
2102- fprintf (stderr , "Can't initialize heap\n" );
2100+ f //printf (stderr, "Can't initialize heap\n");
21032101#endif
21042102 return NULL ;
21052103 }
@@ -2148,7 +2146,7 @@ static zend_mm_heap *zend_mm_init(void)
21482146
21492147ZEND_API size_t zend_mm_gc (zend_mm_heap * heap )
21502148{
2151- printf ("Running gc\n" );
2149+ // printf("Running gc\n");
21522150 zend_mm_free_slot * p , * q ;
21532151 zend_mm_chunk * chunk ;
21542152 size_t page_offset ;
@@ -2196,7 +2194,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
21962194 chunk -> map [page_num ] = ZEND_MM_SRUN_EX (i , free_counter );
21972195
21982196 ZEND_ASAN_POISON_CHUNK_HEADER_NOT_HEAP (chunk , heap );
2199- printf ("Getting next slot from %p during GC\n" , p );
2197+ // printf("Getting next slot from %p during GC\n", p);
22002198 p = zend_mm_get_next_free_slot (heap , i , p );
22012199 }
22022200
@@ -2227,7 +2225,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
22272225 ZEND_MM_ASSERT (ZEND_MM_SRUN_BIN_NUM (info ) == i );
22282226 if (ZEND_MM_SRUN_FREE_COUNTER (info ) == bin_elements [i ]) {
22292227 /* remove from cache */
2230- printf ("Getting next slot from %p during GC (2)\n" , p );
2228+ // printf("Getting next slot from %p during GC (2)\n", p);
22312229 p = zend_mm_get_next_free_slot (heap , i , p );
22322230 if (q == (zend_mm_free_slot * )& heap -> free_slot [i ]) {
22332231 q -> next_free_slot = p ;
@@ -2239,7 +2237,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
22392237 if (q == (zend_mm_free_slot * )& heap -> free_slot [i ]) {
22402238 p = q -> next_free_slot ;
22412239 } else {
2242- printf ("Getting next slot from %p during GC (3)\n" , q );
2240+ // printf("Getting next slot from %p during GC (3)\n", q);
22432241 p = zend_mm_get_next_free_slot (heap , i , q );
22442242 }
22452243 }
@@ -2288,7 +2286,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
22882286 ZEND_ASAN_POISON_CHUNK_HEADER_NOT_HEAP (chunk , heap );
22892287 ZEND_ASAN_POISON_MEMORY_REGION (heap , sizeof (zend_mm_heap ));
22902288
2291- printf ("Done running gc\n" );
2289+ // printf("Done running gc\n");
22922290 return collected * ZEND_MM_PAGE_SIZE ;
22932291}
22942292
@@ -2936,14 +2934,14 @@ ZEND_API void* ZEND_FASTCALL _emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LI
29362934 }
29372935#endif
29382936 void * ptr = zend_mm_alloc_heap (AG (mm_heap ), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC );
2939- printf ("Alloced %p of size %zu\n" , ptr , size );
2937+ // printf("Alloced %p of size %zu\n", ptr, size);
29402938 ZEND_ASAN_POISON_MEMORY_REGION (AG (mm_heap ), sizeof (zend_mm_heap ));
29412939 return ptr ;
29422940}
29432941
29442942ZEND_API void ZEND_FASTCALL _efree (void * ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC )
29452943{
2946- printf ("Freed %p\n" , ptr );
2944+ // printf("Freed %p\n", ptr);
29472945 ZEND_ASAN_UNPOISON_MEMORY_REGION (AG (mm_heap ), sizeof (zend_mm_heap ));
29482946#if ZEND_MM_CUSTOM
29492947 if (UNEXPECTED (AG (mm_heap )-> use_custom_heap )) {
@@ -3163,7 +3161,7 @@ ZEND_API void shutdown_memory_manager(bool silent, bool full_shutdown)
31633161
31643162static ZEND_COLD ZEND_NORETURN void zend_out_of_memory (void )
31653163{
3166- fprintf (stderr , "Out of memory\n" );
3164+ f //printf (stderr, "Out of memory\n");
31673165 exit (1 );
31683166}
31693167
@@ -3472,7 +3470,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void
34723470 chunk = (zend_mm_chunk * )handlers -> chunk_alloc (& tmp_storage , ZEND_MM_CHUNK_SIZE , ZEND_MM_CHUNK_SIZE );
34733471 if (UNEXPECTED (chunk == NULL )) {
34743472#if ZEND_MM_ERROR
3475- fprintf (stderr , "Can't initialize heap\n" );
3473+ f //printf (stderr, "Can't initialize heap\n");
34763474#endif
34773475 return NULL ;
34783476 }
@@ -3517,7 +3515,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void
35173515 if (!storage ) {
35183516 handlers -> chunk_free (& tmp_storage , chunk , ZEND_MM_CHUNK_SIZE );
35193517#if ZEND_MM_ERROR
3520- fprintf (stderr , "Can't initialize heap\n" );
3518+ f //printf (stderr, "Can't initialize heap\n");
35213519#endif
35223520 return NULL ;
35233521 }
0 commit comments