From: dmitry Operating system: * PHP version: 5.4Git-2012-12-13 (Git) Package: Filter related Bug Type: Bug Bug description:getenv() prosuces memory leak with CGI SAPI
Description: ------------ The memory leak is well reproducible with debug build and CGI SAPI. It also possible to see it with valgrind. $ USE_ZEND_ALLOC=0 valgrind --leak-check=full sapi/cgi/php-cgi env.php ==27371== 136 bytes in 1 blocks are definitely lost in loss record 30 of 73 ==27371== at 0x4008F6F: malloc (vg_replace_malloc.c:270) ==27371== by 0x84B1704: _emalloc (zend_alloc.c:2423) ==27371== by 0x84B1B37: _estrndup (zend_alloc.c:2596) ==27371== by 0x81E275D: php_sapi_filter (filter.c:468) ==27371== by 0x846FA0E: sapi_getenv (SAPI.c:1020) ==27371== by 0x8374964: zif_getenv (basic_functions.c:4020) ==27371== by 0x85189ED: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:553) ==27371== by 0x851E497: ZEND_DO_FCALL_SPEC_CONST_HANDLER (zend_vm_execute.h:2302) ==27371== by 0x8517422: execute_ex (zend_vm_execute.h:356) ==27371== by 0x8517B11: zend_execute (zend_vm_execute.h:381) ==27371== by 0x84E06D9: zend_execute_scripts (zend.c:1309) ==27371== by 0x8466F98: php_execute_script (main.c:2468) The leak is relate to JIT initialization of PG(http_globals)[TRACK_VARS_ENV] Test script: --------------- <?php getenv("PATH"); ?> OK Expected result: ---------------- DONE Actual result: -------------- DONE [Thu Dec 13 12:39:18 2012] Script: 'ZZZZZZZZ�nG'�W�$�' /home/dmitry/php/php5.4/ext/filter/filter.c(468) : Freeing 0xF718F3D8 (136 bytes), script=ZZZZZZZZ�nG'�W�$� === Total 1 memory leaks detected === -- Edit bug report at https://bugs.php.net/bug.php?id=63757&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63757&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63757&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63757&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63757&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63757&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63757&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63757&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63757&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63757&r=support Expected behavior: https://bugs.php.net/fix.php?id=63757&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63757&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63757&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63757&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63757&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63757&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63757&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63757&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63757&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63757&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63757&r=mysqlcfg