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

From: Date: Thu, 12 Oct 2017 19:54:03 +0000
Subject: Bug #75368 [NEW]: mmap/munmap trashing on unlucky allocations
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211657@lists.php.net to get a copy of this message
From: nikic Operating system: PHP version: 7.0.24 Package: Scripting Engine problem Bug Type: Bug Bug description:mmap/munmap trashing on unlucky allocations 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 bug report at https://bugs.php.net/bug.php?id=75368&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75368&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75368&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75368&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75368&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75368&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75368&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75368&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75368&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75368&r=support Expected behavior: https://bugs.php.net/fix.php?id=75368&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75368&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75368&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75368&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75368&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75368&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75368&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75368&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75368&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75368&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75368&r=mysqlcfg

« previous php.bugs (#211657) next »