FAQ
Hi all,

I get an error with my program:
Fatal error: Allowed memory size of 134217728 bytes exhausted at /home/courtois/php-5.3.6/Zend/zend_execute.h:163 (tried to allocate 261900 bytes) in /var/www/dev4.sociatomdev.com/chroot/htdocs/templeet/fetch.php on line 580


- The same error occurs with any of php 5.3 versions tested. With 5.2 it's ok.
- I know the error message is wrong. The program does not consume much memory.
- If i change some lines in my php code like adding trace messages it sometimes work sometimes no (but constant result for same php code)


I will not submit the bug since it's hard to reproduce unless being in the exact same configuration as me.

I used to be an experienced C programmer (>300000 lines written) but almost nothing for the last 15 years.

My questions:
- is there any document somewhere to read before hunting a bug in php ?
- are there any build/compile options other than --enable-debug ?
- how should I proceed to debug when php is called via fastcgi ?

My configuration: debian squeeze i386 32bits

Thanks,

Pascal

Search Discussions

  • Pierre Joye at Apr 1, 2011 at 1:20 pm
    hi,

    In php 5.3+ the memory limit default is 256MB, not 128MB. 5.3 does not
    necessary use more memory but actually uses and reports its usage more
    efficiently. I would suggest to use this default value and try again.

    About detecting leaks and memory corruptions, valgrind is a good tool
    to begin with.

    Cheers,
    On Fri, Apr 1, 2011 at 1:27 PM, Pascal COURTOIS wrote:
    Hi all,

    I get an error with my program:
    Fatal error: Allowed memory size of 134217728 bytes exhausted at /home/courtois/php-5.3.6/Zend/zend_execute.h:163 (tried to allocate 261900 bytes) in /var/www/dev4.sociatomdev.com/chroot/htdocs/templeet/fetch.php on line 580


    - The same error occurs with any of php 5.3 versions tested. With 5.2 it's ok.
    - I know the error message is wrong. The program does not consume much memory.
    - If i change some lines in my php code like adding trace messages it sometimes work sometimes no (but constant result for same php code)


    I will not submit the bug since it's hard to reproduce unless being in the exact same configuration as me.

    I used to be an experienced C programmer (>300000 lines written) but almost nothing for the last 15 years.

    My questions:
    - is there any document somewhere to read before hunting a bug in php ?
    - are there any build/compile options other than --enable-debug ?
    - how should I proceed to debug when php is called via fastcgi ?

    My configuration: debian squeeze i386 32bits

    Thanks,

    Pascal

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php


    --
    Pierre

    @pierrejoye | http://blog.thepimp.net | http://www.libgd.org
  • Pascal COURTOIS at Apr 1, 2011 at 4:46 pm

    Le 01/04/2011 15:20, Pierre Joye a écrit :
    hi,

    In php 5.3+ the memory limit default is 256MB, not 128MB. 5.3 does not
    necessary use more memory but actually uses and reports its usage more
    efficiently. I would suggest to use this default value and try again.
    the exact same bug occurs whatever the limit set. Anyway, when it works
    it's ok with 6MB so it's not a matter of quantity obviously.
    About detecting leaks and memory corruptions, valgrind is a good tool
    to begin with.
    It take a look at it.

    Thanks
  • Pascal COURTOIS at Apr 3, 2011 at 10:20 am

    Le 01/04/2011 18:46, Pascal COURTOIS a écrit :
    Le 01/04/2011 15:20, Pierre Joye a écrit :
    hi,

    In php 5.3+ the memory limit default is 256MB, not 128MB. 5.3 does not
    necessary use more memory but actually uses and reports its usage more
    efficiently. I would suggest to use this default value and try again.
    the exact same bug occurs whatever the limit set. Anyway, when it works
    it's ok with 6MB so it's not a matter of quantity obviously.
    further investigations show that my program uses around 3Mbytes of memory BUT
    real_usage memory increases constantly which could suggest either a bug in the
    zend memory manager or a very special condition in my php program making the
    memory manager unable to use holes in its system allocated memory.

    the use of gc_collect_cycles() as suggested privately does not make any difference.
  • Pierre Joye at Apr 3, 2011 at 10:47 am

    On Sun, Apr 3, 2011 at 12:20 PM, Pascal COURTOIS wrote:
    Le 01/04/2011 18:46, Pascal COURTOIS a écrit :
    Le 01/04/2011 15:20, Pierre Joye a écrit :
    hi,

    In php 5.3+ the memory limit default is 256MB, not 128MB. 5.3 does not
    necessary use more memory but actually uses and reports its usage more
    efficiently. I would suggest to use this default value and try again.
    the exact same bug occurs whatever the limit set. Anyway, when it works
    it's ok with 6MB so it's not a matter of quantity obviously.
    further investigations show that my program uses around 3Mbytes of memory BUT
    real_usage memory increases constantly which could suggest either a bug in the
    zend memory manager or a very special condition in my php program making the
    memory manager unable to use holes in its system allocated memory.

    the use of gc_collect_cycles() as suggested privately does not make any difference.
    Try to run it by disabling the zend memory manager:

    USE_ZEND_ALLOC=0 valgrind php --leak-check=full sapi/cli/php ... (or
    httpd if you use apache or only reproducible there)

    That will tell you if there are actual leaks. See Zend/README.ZEND_MM
    for more details

    Cheers,
  • Pascal COURTOIS at Apr 3, 2011 at 10:52 am

    Le 03/04/2011 12:46, Pierre Joye a écrit :

    Try to run it by disabling the zend memory manager:
    with zend memory manager disabled the program works fine.
    I'll try with valgrind as you suggest
  • Pascal COURTOIS at Apr 3, 2011 at 11:12 am

    Le 03/04/2011 12:46, Pierre Joye a écrit :

    USE_ZEND_ALLOC=0 valgrind php --leak-check=full sapi/cli/php ... (or
    httpd if you use apache or only reproducible there)

    That will tell you if there are actual leaks.
    it IS leaking:

    ==9772== Memcheck, a memory error detector
    ==9772== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
    ==9772== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
    ==9772== Command: /home/courtois/php-5.3.6/sapi/cgi/php-cgi
    ==9772==
    /var/www/dev4.sociatomdev.com/chroot/htdocs/templeet/fetch.php(215) : Warning - Cannot modify header information - headers already sent by (output started at /var/www/dev4.sociatomdev.com/chroot/htdocs/templeet/fetch.php:580)
    ==9772==
    ==9772== HEAP SUMMARY:
    ==9772== in use at exit: 60,706 bytes in 1,591 blocks
    ==9772== total heap usage: 1,822,108 allocs, 1,820,517 frees, 303,318,634 bytes allocated
    ==9772==
    ==9772== 21 (20 direct, 1 indirect) bytes in 1 blocks are definitely lost in loss record 27 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x845A07A: zend_assign_to_variable_reference (zend_execute.c:413)
    ==9772== by 0x84E558E: ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER (zend_vm_execute.h:27383)
    ==9772== by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772== by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 21 (20 direct, 1 indirect) bytes in 1 blocks are definitely lost in loss record 28 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x845B3E4: zend_assign_to_variable (zend_execute.c:714)
    ==9772== by 0x84D40A3: ZEND_ASSIGN_SPEC_CV_CONST_HANDLER (zend_vm_execute.h:24059)
    ==9772== by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772== by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 39 bytes in 3 blocks are possibly lost in loss record 46 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772== by 0x83F588F: zend_scan_escape_string (zend_language_scanner.l:740)
    ==9772== by 0x83F74AC: lex_scan (zend_language_scanner.l:2037)
    ==9772== by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772== by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772== by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772== by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772== by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772== by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==
    ==9772== 40 bytes in 2 blocks are definitely lost in loss record 54 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x84CCA39: zend_send_by_var_helper_SPEC_CV (zend_vm_execute.h:22135)
    ==9772== by 0x84CD161: ZEND_SEND_VAR_SPEC_CV_HANDLER (zend_vm_execute.h:22242)
    ==9772== by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772== by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 54 (20 direct, 34 indirect) bytes in 1 blocks are definitely lost in loss record 65 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x845AAC6: zend_assign_to_object (zend_execute.c:558)
    ==9772== by 0x84D38B9: ZEND_ASSIGN_OBJ_SPEC_CV_CONST_HANDLER (zend_vm_execute.h:23966)
    ==9772== by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772== by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 75 bytes in 12 blocks are possibly lost in loss record 73 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772== by 0x83F588F: zend_scan_escape_string (zend_language_scanner.l:740)
    ==9772== by 0x83F9834: lex_scan (zend_language_scanner.l:1870)
    ==9772== by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772== by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772== by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772== by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772== by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772== by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==
    ==9772== 85 bytes in 11 blocks are possibly lost in loss record 77 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772== by 0x8402183: lex_scan (zend_language_scanner.l:1036)
    ==9772== by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772== by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772== by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772== by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772== by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772== by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 92 (80 direct, 12 indirect) bytes in 4 blocks are definitely lost in loss record 82 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x845D63A: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:300)
    ==9772== by 0x84612E1: ZEND_DO_FCALL_SPEC_CONST_HANDLER (zend_vm_execute.h:1606)
    ==9772== by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772== by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 100 bytes in 7 blocks are possibly lost in loss record 84 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x842CCDE: zend_str_tolower_dup (zend_operators.c:1884)
    ==9772== by 0x8414252: zend_do_begin_dynamic_function_call (zend_compile.c:1683)
    ==9772== by 0x8413D94: zend_do_begin_function_call (zend_compile.c:1575)
    ==9772== by 0x83F2378: zendparse (zend_language_parser.c:4652)
    ==9772== by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772== by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772== by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772== by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 100 bytes in 12 blocks are possibly lost in loss record 85 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772== by 0x83FA90D: lex_scan (zend_language_scanner.l:1672)
    ==9772== by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772== by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772== by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772== by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772== by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772== by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 122 bytes in 9 blocks are possibly lost in loss record 90 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772== by 0x83F820E: lex_scan (zend_language_scanner.l:1695)
    ==9772== by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772== by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772== by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772== by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772== by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772== by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 182 bytes in 14 blocks are possibly lost in loss record 100 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772== by 0x83F9637: lex_scan (zend_language_scanner.l:1817)
    ==9772== by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772== by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772== by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772== by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772== by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772== by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 322 bytes in 34 blocks are possibly lost in loss record 112 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x842CCDE: zend_str_tolower_dup (zend_operators.c:1884)
    ==9772== by 0x8413D39: zend_do_begin_function_call (zend_compile.c:1571)
    ==9772== by 0x83F2378: zendparse (zend_language_parser.c:4652)
    ==9772== by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772== by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772== by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772== by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 482 (144 direct, 338 indirect) bytes in 1 blocks are definitely lost in loss record 116 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x83F5086: compile_file (zend_language_scanner.l:334)
    ==9772== by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772== by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772== by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 613 (60 direct, 553 indirect) bytes in 3 blocks are definitely lost in loss record 117 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x84CCFF2: ZEND_SEND_REF_SPEC_CV_HANDLER (zend_vm_execute.h:22226)
    ==9772== by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772== by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 679 (120 direct, 559 indirect) bytes in 6 blocks are definitely lost in loss record 121 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x845B497: zend_assign_to_variable (zend_execute.c:724)
    ==9772== by 0x84DB447: ZEND_ASSIGN_SPEC_CV_TMP_HANDLER (zend_vm_execute.h:25697)
    ==9772== by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772== by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 14,467 (88 direct, 14,379 indirect) bytes in 2 blocks are definitely lost in loss record 135 of 136
    ==9772== at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772== by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772== by 0x8423FFC: zend_rebuild_symbol_table (zend_execute_API.c:1699)
    ==9772== by 0x845B588: zend_get_target_symbol_table (zend_execute.c:766)
    ==9772== by 0x846082C: zend_fetch_var_address_helper_SPEC_CONST (zend_vm_execute.h:1340)
    ==9772== by 0x8460EA0: ZEND_FETCH_R_SPEC_CONST_HANDLER (zend_vm_execute.h:1424)
    ==9772== by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772== by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 17,328 bytes in 1 blocks are possibly lost in loss record 136 of 136
    ==9772== at 0x4024046: realloc (vg_replace_malloc.c:525)
    ==9772== by 0x840F392: _erealloc (zend_alloc.c:2391)
    ==9772== by 0x8425C72: pass_two (zend_opcode.c:380)
    ==9772== by 0x83F51DB: compile_file (zend_language_scanner.l:376)
    ==9772== by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772== by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772== by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772== by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772== by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== LEAK SUMMARY:
    ==9772== definitely lost: 592 bytes in 21 blocks
    ==9772== indirectly lost: 15,877 bytes in 524 blocks
    ==9772== possibly lost: 18,353 bytes in 103 blocks
    ==9772== still reachable: 25,884 bytes in 943 blocks
    ==9772== suppressed: 0 bytes in 0 blocks
    ==9772== Reachable blocks (those to which a pointer was found) are not shown.
    ==9772== To see them, rerun with: --leak-check=full --show-reachable=yes
    ==9772==
    ==9772== For counts of detected and suppressed errors, rerun with: -v
    ==9772== ERROR SUMMARY: 18 errors from 18 contexts (suppressed: 38 from 11)
  • Patrick ALLAERT at Apr 3, 2011 at 1:46 pm

    2011/4/3 Pascal COURTOIS <Pascal.Courtois@nouvo.com>:
    Le 03/04/2011 12:46, Pierre Joye a écrit :
    USE_ZEND_ALLOC=0 valgrind php --leak-check=full sapi/cli/php ... (or
    httpd if you use apache or only reproducible there)

    That will tell you if there are actual leaks.
    it IS leaking:

    ==9772== Memcheck, a memory error detector
    ==9772== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
    ==9772== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
    ==9772== Command: /home/courtois/php-5.3.6/sapi/cgi/php-cgi
    ==9772==
    /var/www/dev4.sociatomdev.com/chroot/htdocs/templeet/fetch.php(215) : Warning - Cannot modify header information - headers already sent by (output started at /var/www/dev4.sociatomdev.com/chroot/htdocs/templeet/fetch.php:580)
    ==9772==
    ==9772== HEAP SUMMARY:
    ==9772==     in use at exit: 60,706 bytes in 1,591 blocks
    ==9772==   total heap usage: 1,822,108 allocs, 1,820,517 frees, 303,318,634 bytes allocated
    ==9772==
    ==9772== 21 (20 direct, 1 indirect) bytes in 1 blocks are definitely lost in loss record 27 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x845A07A: zend_assign_to_variable_reference (zend_execute.c:413)
    ==9772==    by 0x84E558E: ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER (zend_vm_execute.h:27383)
    ==9772==    by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772==    by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 21 (20 direct, 1 indirect) bytes in 1 blocks are definitely lost in loss record 28 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x845B3E4: zend_assign_to_variable (zend_execute.c:714)
    ==9772==    by 0x84D40A3: ZEND_ASSIGN_SPEC_CV_CONST_HANDLER (zend_vm_execute.h:24059)
    ==9772==    by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772==    by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 39 bytes in 3 blocks are possibly lost in loss record 46 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772==    by 0x83F588F: zend_scan_escape_string (zend_language_scanner.l:740)
    ==9772==    by 0x83F74AC: lex_scan (zend_language_scanner.l:2037)
    ==9772==    by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772==    by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772==    by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772==    by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772==    by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772==    by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==
    ==9772== 40 bytes in 2 blocks are definitely lost in loss record 54 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x84CCA39: zend_send_by_var_helper_SPEC_CV (zend_vm_execute.h:22135)
    ==9772==    by 0x84CD161: ZEND_SEND_VAR_SPEC_CV_HANDLER (zend_vm_execute.h:22242)
    ==9772==    by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772==    by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 54 (20 direct, 34 indirect) bytes in 1 blocks are definitely lost in loss record 65 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x845AAC6: zend_assign_to_object (zend_execute.c:558)
    ==9772==    by 0x84D38B9: ZEND_ASSIGN_OBJ_SPEC_CV_CONST_HANDLER (zend_vm_execute.h:23966)
    ==9772==    by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772==    by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 75 bytes in 12 blocks are possibly lost in loss record 73 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772==    by 0x83F588F: zend_scan_escape_string (zend_language_scanner.l:740)
    ==9772==    by 0x83F9834: lex_scan (zend_language_scanner.l:1870)
    ==9772==    by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772==    by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772==    by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772==    by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772==    by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772==    by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==
    ==9772== 85 bytes in 11 blocks are possibly lost in loss record 77 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772==    by 0x8402183: lex_scan (zend_language_scanner.l:1036)
    ==9772==    by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772==    by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772==    by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772==    by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772==    by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772==    by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 92 (80 direct, 12 indirect) bytes in 4 blocks are definitely lost in loss record 82 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x845D63A: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:300)
    ==9772==    by 0x84612E1: ZEND_DO_FCALL_SPEC_CONST_HANDLER (zend_vm_execute.h:1606)
    ==9772==    by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772==    by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 100 bytes in 7 blocks are possibly lost in loss record 84 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x842CCDE: zend_str_tolower_dup (zend_operators.c:1884)
    ==9772==    by 0x8414252: zend_do_begin_dynamic_function_call (zend_compile.c:1683)
    ==9772==    by 0x8413D94: zend_do_begin_function_call (zend_compile.c:1575)
    ==9772==    by 0x83F2378: zendparse (zend_language_parser.c:4652)
    ==9772==    by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772==    by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772==    by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772==    by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 100 bytes in 12 blocks are possibly lost in loss record 85 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772==    by 0x83FA90D: lex_scan (zend_language_scanner.l:1672)
    ==9772==    by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772==    by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772==    by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772==    by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772==    by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772==    by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 122 bytes in 9 blocks are possibly lost in loss record 90 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772==    by 0x83F820E: lex_scan (zend_language_scanner.l:1695)
    ==9772==    by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772==    by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772==    by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772==    by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772==    by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772==    by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 182 bytes in 14 blocks are possibly lost in loss record 100 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x840F685: _estrndup (zend_alloc.c:2525)
    ==9772==    by 0x83F9637: lex_scan (zend_language_scanner.l:1817)
    ==9772==    by 0x841CEEE: zendlex (zend_compile.c:4954)
    ==9772==    by 0x83EF882: zendparse (zend_language_parser.c:3280)
    ==9772==    by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772==    by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772==    by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772==    by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 322 bytes in 34 blocks are possibly lost in loss record 112 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x842CCDE: zend_str_tolower_dup (zend_operators.c:1884)
    ==9772==    by 0x8413D39: zend_do_begin_function_call (zend_compile.c:1571)
    ==9772==    by 0x83F2378: zendparse (zend_language_parser.c:4652)
    ==9772==    by 0x83F517F: compile_file (zend_language_scanner.l:364)
    ==9772==    by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772==    by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772==    by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 482 (144 direct, 338 indirect) bytes in 1 blocks are definitely lost in loss record 116 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x83F5086: compile_file (zend_language_scanner.l:334)
    ==9772==    by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772==    by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772==    by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 613 (60 direct, 553 indirect) bytes in 3 blocks are definitely lost in loss record 117 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x84CCFF2: ZEND_SEND_REF_SPEC_CV_HANDLER (zend_vm_execute.h:22226)
    ==9772==    by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772==    by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 679 (120 direct, 559 indirect) bytes in 6 blocks are definitely lost in loss record 121 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x845B497: zend_assign_to_variable (zend_execute.c:724)
    ==9772==    by 0x84DB447: ZEND_ASSIGN_SPEC_CV_TMP_HANDLER (zend_vm_execute.h:25697)
    ==9772==    by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772==    by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 14,467 (88 direct, 14,379 indirect) bytes in 2 blocks are definitely lost in loss record 135 of 136
    ==9772==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    ==9772==    by 0x840F2D1: _emalloc (zend_alloc.c:2370)
    ==9772==    by 0x8423FFC: zend_rebuild_symbol_table (zend_execute_API.c:1699)
    ==9772==    by 0x845B588: zend_get_target_symbol_table (zend_execute.c:766)
    ==9772==    by 0x846082C: zend_fetch_var_address_helper_SPEC_CONST (zend_vm_execute.h:1340)
    ==9772==    by 0x8460EA0: ZEND_FETCH_R_SPEC_CONST_HANDLER (zend_vm_execute.h:1424)
    ==9772==    by 0x845CE46: execute (zend_vm_execute.h:107)
    ==9772==    by 0x8430173: zend_execute_scripts (zend.c:1194)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== 17,328 bytes in 1 blocks are possibly lost in loss record 136 of 136
    ==9772==    at 0x4024046: realloc (vg_replace_malloc.c:525)
    ==9772==    by 0x840F392: _erealloc (zend_alloc.c:2391)
    ==9772==    by 0x8425C72: pass_two (zend_opcode.c:380)
    ==9772==    by 0x83F51DB: compile_file (zend_language_scanner.l:376)
    ==9772==    by 0x8265A34: phar_compile_file (phar.c:3393)
    ==9772==    by 0x83AEE26: xc_check_initial_compile_file (xcache.c:929)
    ==9772==    by 0x84300D3: zend_execute_scripts (zend.c:1186)
    ==9772==    by 0x83C70C8: php_execute_script (main.c:2268)
    ==9772==    by 0x84F4A3A: main (cgi_main.c:2109)
    ==9772==
    ==9772== LEAK SUMMARY:
    ==9772==    definitely lost: 592 bytes in 21 blocks
    ==9772==    indirectly lost: 15,877 bytes in 524 blocks
    ==9772==      possibly lost: 18,353 bytes in 103 blocks
    ==9772==    still reachable: 25,884 bytes in 943 blocks
    ==9772==         suppressed: 0 bytes in 0 blocks
    ==9772== Reachable blocks (those to which a pointer was found) are not shown.
    ==9772== To see them, rerun with: --leak-check=full --show-reachable=yes
    ==9772==
    ==9772== For counts of detected and suppressed errors, rerun with: -v
    ==9772== ERROR SUMMARY: 18 errors from 18 contexts (suppressed: 38 from 11)
    Sounds like "now" is a good time to fill in a bug report at
    http://bugs.php.net/ :)
    Don't forget to add valgrind's output.

    Patrick
  • Pascal COURTOIS at Apr 3, 2011 at 4:28 pm

    Le 03/04/2011 15:46, Patrick ALLAERT a écrit :

    Sounds like "now" is a good time to fill in a bug report at
    http://bugs.php.net/ :)
    The trouble is I don't know how to fill in such bug report.
    It happens with my template engine which is thousands of lines
    of PHP. The template engine has been used since 2003 and the
    bug appears with one single template which has nothing particular.

    I guess if I make a bug report with all instructions to reproduce
    the bug no one will ever look at it because it means installing
    the framework. Ok, the installer does the job in 5 seconds but knowing
    the number of open tickets in PHP, if I was a zend developper I'm
    not sure I would look in priority in a bug which is hard to reproduce. :-(

    What do you think ?
  • Pierre Joye at Apr 3, 2011 at 6:37 pm
    post it with the necessary steps to reproduce it. We may try to reduce
    the code to the minimal we need to get the leak (I remember someone
    having a tool for that)

    On Sun, Apr 3, 2011 at 6:27 PM, Pascal COURTOIS
    wrote:
    Le 03/04/2011 15:46, Patrick ALLAERT a écrit :
    Sounds like "now" is a good time to fill in a bug report at
    http://bugs.php.net/ :)
    The trouble is I don't know how to fill in such bug report.
    It happens with my template engine which is thousands of lines
    of PHP. The template engine has been used since 2003 and the
    bug appears with one single template which has nothing particular.

    I guess if I make a bug report with all instructions to reproduce
    the bug no one will ever look at it because it means installing
    the framework. Ok, the installer does the job in 5 seconds but knowing
    the number of open tickets in PHP, if I was a zend developper I'm
    not sure I would look in priority in a bug which is hard to reproduce. :-(

    What do you think ?

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php


    --
    Pierre

    @pierrejoye | http://blog.thepimp.net | http://www.libgd.org
  • Pascal COURTOIS at Apr 3, 2011 at 7:30 pm

    Le 03/04/2011 20:37, Pierre Joye a écrit :
    post it with the necessary steps to reproduce it. We may try to reduce
    the code to the minimal we need to get the leak (I remember someone
    having a tool for that)
    ok, thanks: http://bugs.php.net/bug.php?id=54460

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedApr 1, '11 at 1:15p
activeApr 3, '11 at 7:30p
posts11
users4
websitephp.net

People

Translate

site design / logo © 2022 Grokbase