Bug #70481 [NEW]: Memory leak in auto_global_copy_ctor()

From: Date: Sun, 13 Sep 2015 15:46:07 +0000
Subject: Bug #70481 [NEW]: Memory leak in auto_global_copy_ctor()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195983@lists.php.net to get a copy of this message
From: sathya at laufers dot net Operating system: Ubuntu 14.04 PHP version: 7.0.0RC2 Package: Unknown/Other Function Bug Type: Bug Bug description:Memory leak in auto_global_copy_ctor() Description: ------------ I'm using the PHP embed library with ZTS enabled in a program of mine and just switched to PHP7. Using valgrind to search for memory leaks I noticed that memory allocated in auto_global_copy_ctor() in Zend/zend.c is not freed in compiler_globals_dtor() causing a memory leak of (global_auto_globals_table->nNumUsed * sizeof(zend_auto_global)) Bytes for every new thread. Here's the full valgrind output: ==6621== ==6621== HEAP SUMMARY: ==6621== in use at exit: 192,047 bytes in 2,902 blocks ==6621== total heap usage: 1,224,943 allocs, 1,222,041 frees, 123,484,720 bytes allocated ==6621== ==6621== 416 (216 direct, 200 indirect) bytes in 9 blocks are definitely lost in loss record 91 of 152 ==6621== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6621== by 0x5B3AB5: auto_global_copy_ctor (zend_alloc.h:192) ==6621== by 0x5C7EFB: zend_hash_copy (zend_hash.c:1601) ==6621== by 0x5B384C: compiler_globals_ctor (zend.c:499) ==6621== by 0x5B4C24: zend_post_startup (zend.c:832) ==6621== by 0x551565: php_module_startup (main.c:2220) . . . ==6621== ==6621== 2,264 (2,160 direct, 104 indirect) bytes in 90 blocks are definitely lost in loss record 135 of 152 ==6621== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6621== by 0x5B3AB5: auto_global_copy_ctor (zend_alloc.h:192) ==6621== by 0x5C7EFB: zend_hash_copy (zend_hash.c:1601) ==6621== by 0x5B384C: compiler_globals_ctor (zend.c:499) ==6621== by 0x54E671: allocate_new_resource (TSRM.c:301) ==6621== by 0x54E798: ts_resource_ex (TSRM.c:368) . . . ==6621== by 0x4E3F181: start_thread (pthread_create.c:312) ==6621== ==6621== LEAK SUMMARY: ==6621== definitely lost: 2,376 bytes in 99 blocks ==6621== indirectly lost: 304 bytes in 9 blocks ==6621== possibly lost: 0 bytes in 0 blocks ==6621== still reachable: 189,367 bytes in 2,794 blocks ==6621== suppressed: 0 bytes in 0 blocks ==6621== Reachable blocks (those to which a pointer was found) are not shown. ==6621== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==6621== ==6621== For counts of detected and suppressed errors, rerun with: -v ==6621== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) I didn't do much more digging than this and didn't have the time to come up with a patch. I figured you guys are much faster in fixing this than I am ;-). Cheers, Sathya -- Edit bug report at https://bugs.php.net/bug.php?id=70481&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70481&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70481&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70481&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70481&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70481&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70481&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70481&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70481&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70481&r=support Expected behavior: https://bugs.php.net/fix.php?id=70481&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70481&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70481&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70481&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70481&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70481&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70481&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70481&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70481&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70481&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70481&r=mysqlcfg

« previous php.bugs (#195983) next »