Here the result of valgrind, thanks to Derick! Now gurus can analyse the result.
Something wrong in implode() function? Jean-Pierre #!/usr/local/bin/php -c/usr/local/php/etc/php_cli.ini <?php $a= array ( 'XXXXX_XXXX' => 'ZZZZ DDD2 17 C', 'XXXXXX_1' => '0.00', 'XXXXXXX_1' => '0.00', 'BBB' => '0.00', 'AAA' => '0.00', 'YYY_YYYYY' => '18.06', 'AAAAA_1' => '0', 'SSSSSS_PPP' => '17', 'PPPPPPPPPP' => 'C-AM', 'EEEEE_DATE' => '30 DEC 2003', 'TTTTTT_T' => ':', 'RRRRR_DATE' => '-', 'WWWDATE' => -1, 'STAMP' => '- :', ); $xml=array(); for($i=0;$i<150;$i++){ $xml['ZZZZ6000R.Q'.$i]=$a; } $xxa=array_keys($xml); echo ' BEFORE ';flush(); $xxi=implode(',',$xxa); echo ' AFTER ';flush(); ?> shell> valgrind -v --leak-check=yes php bug_php.php --ug 434 ==17820== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux. ==17820== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward. ==17820== Using valgrind-2.0.0, a program supervision framework for x86-linux. ==17820== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward. ==17820== Command line: ==17820== php ==17820== bug_php.php ==17820== --ug ==17820== 434 ==17820== Startup, with flags: ==17820== --suppressions=/usr/local/lib/valgrind/default.supp ==17820== -v ==17820== --leak-check=yes ==17820== Reading syms from /usr/local/bin/php ==17820== Reading syms from /lib/ld-2.2.4.so ==17820== Reading syms from /usr/local/lib/valgrind/vgskin_memcheck.so ==17820== Reading syms from /usr/local/lib/valgrind/valgrind.so ==17820== Reading syms from /lib/libcrypt-2.2.4.so ==17820== Reading syms from /lib/libpam.so.0.75 ==17820== object doesn't have any debug info ==17820== Reading syms from /usr/lib/libpng.so.2.1.0.14 ==17820== object doesn't have a symbol table ==17820== object doesn't have any debug info ==17820== Reading syms from /usr/lib/libz.so.1.1.4 ==17820== object doesn't have any debug info ==17820== Reading syms from /lib/libdl-2.2.4.so ==17820== Reading syms from /usr/lib/libbz2.so.1.0.0 ==17820== object doesn't have any debug info ==17820== Reading syms from /lib/libresolv-2.2.4.so ==17820== Reading syms from /lib/i686/libm-2.2.4.so ==17820== Reading syms from /lib/libnsl-2.2.4.so ==17820== Reading syms from /usr/local/lib/libcurl.so.2.0.2 ==17820== Reading syms from /lib/libssl.so.0.9.6b ==17820== object doesn't have any debug info ==17820== Reading syms from /lib/libcrypto.so.0.9.6b ==17820== object doesn't have any debug info ==17820== Reading syms from /lib/i686/libc-2.2.4.so ==17820== Reading suppressions file: /usr/local/lib/valgrind/default.supp ==17820== Estimated CPU clock rate is 1615 MHz ==17820== ==17820== Reading syms from /lib/libnss_files-2.2.4.so BEFORE ==17820== Invalid read of size 2 ==17820== at 0x8186883: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:289) ==17820== by 0x81A416F: zend_ptr_stack_clear_multiple (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:96) ==17820== by 0x81A1326: execute (/home/jpa/dev/php-4.3.4/Zend/zend_execute.c:1695) ==17820== by 0x8190A3D: zend_execute_scripts (/home/jpa/dev/php-4.3.4/Zend/zend.c:884) ==17820== Address 0x4263EBA2 is 46 bytes inside a block of size 56 free'd ==17820== at 0x4002BE5B: free (vg_replace_malloc.c:231) ==17820== by 0x817F43E: _efree (/home/jpa/dev/php-4.3.4/Zend/zend_alloc.c:265) ==17820== by 0x8187D4E: safe_free_zval_ptr (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:44) ==17820== by 0x81868B9: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:292) ==17820== ==17820== Invalid read of size 2 ==17820== at 0x818688C: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:290) ==17820== by 0x81A416F: zend_ptr_stack_clear_multiple (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:96) ==17820== by 0x81A1326: execute (/home/jpa/dev/php-4.3.4/Zend/zend_execute.c:1695) ==17820== by 0x8190A3D: zend_execute_scripts (/home/jpa/dev/php-4.3.4/Zend/zend.c:884) ==17820== Address 0x4263EBA2 is 46 bytes inside a block of size 56 free'd ==17820== at 0x4002BE5B: free (vg_replace_malloc.c:231) ==17820== by 0x817F43E: _efree (/home/jpa/dev/php-4.3.4/Zend/zend_alloc.c:265) ==17820== by 0x8187D4E: safe_free_zval_ptr (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:44) ==17820== by 0x81868B9: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:292) ==17820== ==17820== Invalid read of size 2 ==17820== at 0x81868C5: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:293) ==17820== by 0x81A416F: zend_ptr_stack_clear_multiple (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:96) ==17820== by 0x81A1326: execute (/home/jpa/dev/php-4.3.4/Zend/zend_execute.c:1695) ==17820== by 0x8190A3D: zend_execute_scripts (/home/jpa/dev/php-4.3.4/Zend/zend.c:884) ==17820== Address 0x4263EBA2 is 46 bytes inside a block of size 56 free'd ==17820== at 0x4002BE5B: free (vg_replace_malloc.c:231) ==17820== by 0x817F43E: _efree (/home/jpa/dev/php-4.3.4/Zend/zend_alloc.c:265) ==17820== by 0x8187D4E: safe_free_zval_ptr (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:44) ==17820== by 0x81868B9: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:292) AFTER ==17820== ==17820== ERROR SUMMARY: 4 errors from 3 contexts (suppressed: 3 from 1) ==17820== ==17820== 1 errors in context 1 of 3: ==17820== Invalid read of size 2 ==17820== at 0x81868C5: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:293) ==17820== by 0x81A416F: zend_ptr_stack_clear_multiple (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:96) ==17820== by 0x81A1326: execute (/home/jpa/dev/php-4.3.4/Zend/zend_execute.c:1695) ==17820== by 0x8190A3D: zend_execute_scripts (/home/jpa/dev/php-4.3.4/Zend/zend.c:884) ==17820== Address 0x4263EBA2 is 46 bytes inside a block of size 56 free'd ==17820== at 0x4002BE5B: free (vg_replace_malloc.c:231) ==17820== by 0x817F43E: _efree (/home/jpa/dev/php-4.3.4/Zend/zend_alloc.c:265) ==17820== by 0x8187D4E: safe_free_zval_ptr (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:44) ==17820== by 0x81868B9: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:292) ==17820== ==17820== 1 errors in context 2 of 3: ==17820== Invalid read of size 2 ==17820== at 0x818688C: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:290) ==17820== by 0x81A416F: zend_ptr_stack_clear_multiple (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:96) ==17820== by 0x81A1326: execute (/home/jpa/dev/php-4.3.4/Zend/zend_execute.c:1695) ==17820== by 0x8190A3D: zend_execute_scripts (/home/jpa/dev/php-4.3.4/Zend/zend.c:884) ==17820== Address 0x4263EBA2 is 46 bytes inside a block of size 56 free'd ==17820== at 0x4002BE5B: free (vg_replace_malloc.c:231) ==17820== by 0x817F43E: _efree (/home/jpa/dev/php-4.3.4/Zend/zend_alloc.c:265) ==17820== by 0x8187D4E: safe_free_zval_ptr (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:44) ==17820== by 0x81868B9: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:292) ==17820== ==17820== 2 errors in context 3 of 3: ==17820== Invalid read of size 2 ==17820== at 0x8186883: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:289) ==17820== by 0x81A416F: zend_ptr_stack_clear_multiple (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:96) ==17820== by 0x81A1326: execute (/home/jpa/dev/php-4.3.4/Zend/zend_execute.c:1695) ==17820== by 0x8190A3D: zend_execute_scripts (/home/jpa/dev/php-4.3.4/Zend/zend.c:884) ==17820== Address 0x4263EBA2 is 46 bytes inside a block of size 56 free'd ==17820== at 0x4002BE5B: free (vg_replace_malloc.c:231) ==17820== by 0x817F43E: _efree (/home/jpa/dev/php-4.3.4/Zend/zend_alloc.c:265) ==17820== by 0x8187D4E: safe_free_zval_ptr (/home/jpa/dev/php-4.3.4/Zend/zend_execute.h:44) ==17820== by 0x81868B9: _zval_ptr_dtor (/home/jpa/dev/php-4.3.4/Zend/zend_execute_API.c:292) --17820-- --17820-- supp: 3 _dl_relocate_object/libc-2.2.4.so/_dl_catch_error(Cond) ==17820== ==17820== IN SUMMARY: 4 errors from 3 contexts (suppressed: 3 from 1) ==17820== ==17820== malloc/free: in use at exit: 924 bytes in 7 blocks. ==17820== malloc/free: 17447 allocs, 17440 frees, 3337750 bytes allocated. ==17820== ==17820== searching for pointers to 7 not-freed blocks. ==17820== checked 8276972 bytes. ==17820== ==17820== LEAK SUMMARY: ==17820== definitely lost: 0 bytes in 0 blocks. ==17820== possibly lost: 0 bytes in 0 blocks. ==17820== still reachable: 924 bytes in 7 blocks. ==17820== suppressed: 0 bytes in 0 blocks. ==17820== Reachable blocks (those to which a pointer was found) are not shown. ==17820== To see them, rerun with: --show-reachable=yes ==17820== --17820-- TT/TC: 0 tc sectors discarded. --17820-- 9118 chainings, 0 unchainings. --17820-- translate: new 12574 (211072 -> 2966498; ratio 140:10) --17820-- discard 0 (0 -> 0; ratio 0:10). --17820-- dispatch: 6850000 jumps (bb entries), of which 810191 (11%) were unchained. --17820-- 139/52227 major/minor sched events. 17402 tt_fast misses. --17820-- reg-alloc: 2068 t-req-spill, 558773+9763 orig+spill uis, 63291 total-reg-r. --17820-- sanity: 140 cheap, 6 expensive checks. --17820-- ccalls: 72861 C calls, 62% saves+restores avoided (270194 bytes) --17820-- 95773 args, avg 0.89 setup instrs each (20064 bytes) --17820-- 0% clear the stack (218583 bytes) --17820-- 21133 retvals, 30% of reg-reg movs avoided (12658 bytes) ----- Original Message ----- From: "Derick Rethans" <[EMAIL PROTECTED]> To: "Jean-Pierre Arneodo" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]>; "Andi Gutmans" <[EMAIL PROTECTED]> Sent: Wednesday, November 26, 2003 12:27 PM Subject: Re: [PHP-DEV] Segmentation fault in v4.3.4 > On Wed, 26 Nov 2003, Jean-Pierre Arneodo wrote: > > > The script uses 3 extensions a lot: > > - xml: EXPAT Version 1.95.6 > > - curl: libcurl/7.10.2 OpenSSL/0.9.6b zlib/1.1.4 > > - mysql: Client API version 4.0.15 (The MySQL server and lib on the host > > is a 4.0.16) > > > > 80 classes are involved, it is difficult to reduce the script to 20 lines. > > The segfault is data depending. it doesn't happen every time. > > > > My first idea was to rebuild the cli to have a core dump on segfault we can > > analyse. > > But with the --enable-debug configure flag, no segfault :-( > > but some traces. > > > > Any direction to investigate? > > Have a look at the valgrind tool. Use it on a debug build of PHP like > this: > > valgrind php <yourscript> > > it should spit out memory problems then. > > Derick -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php