Edit report at https://bugs.php.net/bug.php?id=63757&edit=1
ID: 63757 Updated by: dmi...@php.net Reported by: dmi...@php.net Summary: getenv() prosuces memory leak with CGI SAPI Status: Closed Type: Bug Package: Filter related Operating System: * PHP Version: 5.4Git-2012-12-13 (Git) Assigned To: dmitry Block user comment: N Private report: N New Comment: The fix for this bug has been committed. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2012-12-13 09:40:50] dmi...@php.net Automatic comment on behalf of dmi...@zend.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=35f86d24d81b81e8c755e82d0b2e76d36f4a0201 Log: Fixed bug #63757 (getenv() produces memory leak with CGI SAPI) ------------------------------------------------------------------------ [2012-12-13 08:45:13] dmi...@php.net 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 this bug report at https://bugs.php.net/bug.php?id=63757&edit=1