Bug #75368 [Opn]: mmap/munmap trashing on unlucky allocations

From: Date: Fri, 13 Oct 2017 06:46:36 +0000
Subject: Bug #75368 [Opn]: mmap/munmap trashing on unlucky allocations
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211666@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75368&edit=1 ID: 75368 Updated by: laruence@php.net Reported by: nikic@php.net Summary: mmap/munmap trashing on unlucky allocations Status: Open Type: Bug Package: Scripting Engine problem PHP Version: 7.0.24 Block user comment: N Private report: N New Comment: it may still be triggered by i = 94 * 2 if you cache one chunk Previous Comments: ------------------------------------------------------------------------ [2017-10-12 19:53:59] nikic@php.net Description: ------------ It may happen that memory is allocated and freed in such a way that the allocation mmaps a new ZMM chunk and the deallocation immediately unmaps it again. The attached script demonstrates this issues. It will execute quickly up to a certain point (for me on master i=94) and then hang for a while. strace shows that during this time a sequence of mmap, madvise and munmap is repeated many times: mmap(NULL, 2097152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3927400000 madvise(0x7f3927400000, 2097152, MADV_HUGEPAGE) = 0 munmap(0x7f3927400000, 2097152) = 0 This issue may be fixed by ensuring we always cache at least one chunk. Test script: --------------- <?php $bigArray = range(0, 256 * 1024 - 1); var_dump(memory_get_usage(true) / (1024*1024)); $array = []; for ($i = 0; $i < 1024; $i++) { echo "$i\n"; $array[] = range(0, 1023); for ($j = 0; $j < 16 * 1024; $j++) { $x = range(0, 1023); unset($x); } } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75368&edit=1

« previous php.bugs (#211666) next »