On Wed, 15 Oct 2008, Krister Karlström wrote:

> Thanks for the advice Derick, valgrind gave this output with USE_ZEND_ALLOC
> set to 0:

This gives a very good clue - for some reason there is not enough memory 
allocated in the emalloc() call on line 911 of ext/mssql/php_mssql.c. 
For some reason the dbconvert() call writes more than it's supposed to 
do. I do not know the libsybdb library well enough to explain why 
though. :/

> 
> ==29752== Memcheck, a memory error detector.
> ==29752== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
> ==29752== Using LibVEX rev 1854, a library for dynamic binary translation.
> ==29752== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
> ==29752== Using valgrind-3.3.1, a dynamic binary instrumentation framework.
> ==29752== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
> ==29752== For more details, rerun with: -v
> ==29752==
> ==29752== Invalid write of size 1
> ==29752==    at 0x4024D57: memcpy (mc_replace_strmem.c:402)
> ==29752==    by 0x406B0C1: dbconvert (in /usr/lib/libsybdb.so.5.0.0)
> ==29752==    by 0x80997F9: php_mssql_get_column_content_with_type
> (php_mssql.c:912)
> ==29752==    by 0x809A791: _mssql_fetch_batch (php_mssql.c:1140)
> ==29752==    by 0x809AF19: zif_mssql_query (php_mssql.c:1263)
> ==29752==    by 0x81C88DC: zend_do_fcall_common_helper_SPEC
> (zend_vm_execute.h:200)
> ==29752==    by 0x81CE2B2: ZEND_DO_FCALL_SPEC_CONST_HANDLER
> (zend_vm_execute.h:1679)
> ==29752==    by 0x81C842F: execute (zend_vm_execute.h:92)
> ==29752==    by 0x81A390F: zend_execute_scripts (zend.c:1134)
> ==29752==    by 0x8151090: php_execute_script (main.c:2005)
> ==29752==    by 0x821FEE5: main (php_cli.c:1140)
> ==29752==  Address 0x43c1711 is 0 bytes after a block of size 25 alloc'd
> ==29752==    at 0x4022AE8: malloc (vg_replace_malloc.c:207)
> ==29752==    by 0x8186640: _emalloc (zend_alloc.c:2280)
> ==29752==    by 0x8099794: php_mssql_get_column_content_with_type
> (php_mssql.c:911)
> ==29752==    by 0x809A791: _mssql_fetch_batch (php_mssql.c:1140)
> ==29752==    by 0x809AF19: zif_mssql_query (php_mssql.c:1263)
> ==29752==    by 0x81C88DC: zend_do_fcall_common_helper_SPEC
> (zend_vm_execute.h:200)
> ==29752==    by 0x81CE2B2: ZEND_DO_FCALL_SPEC_CONST_HANDLER
> (zend_vm_execute.h:1679)
> ==29752==    by 0x81C842F: execute (zend_vm_execute.h:92)
> ==29752==    by 0x81A390F: zend_execute_scripts (zend.c:1134)
> ==29752==    by 0x8151090: php_execute_script (main.c:2005)
> ==29752==    by 0x821FEE5: main (php_cli.c:1140)
> ==29752==
> ==29752== Invalid write of size 1
> ==29752==    at 0x406B0CA: dbconvert (in /usr/lib/libsybdb.so.5.0.0)
> ==29752==    by 0x80997F9: php_mssql_get_column_content_with_type
> (php_mssql.c:912)
> ==29752==    by 0x809A791: _mssql_fetch_batch (php_mssql.c:1140)
> ==29752==    by 0x809AF19: zif_mssql_query (php_mssql.c:1263)
> ==29752==    by 0x81C88DC: zend_do_fcall_common_helper_SPEC
> (zend_vm_execute.h:200)
> ==29752==    by 0x81CE2B2: ZEND_DO_FCALL_SPEC_CONST_HANDLER
> (zend_vm_execute.h:1679)
> ==29752==    by 0x81C842F: execute (zend_vm_execute.h:92)
> ==29752==    by 0x81A390F: zend_execute_scripts (zend.c:1134)
> ==29752==    by 0x8151090: php_execute_script (main.c:2005)
> ==29752==    by 0x821FEE5: main (php_cli.c:1140)
> ==29752==  Address 0x43c1712 is 1 bytes after a block of size 25 alloc'd
> ==29752==    at 0x4022AE8: malloc (vg_replace_malloc.c:207)
> ==29752==    by 0x8186640: _emalloc (zend_alloc.c:2280)
> ==29752==    by 0x8099794: php_mssql_get_column_content_with_type
> (php_mssql.c:911)
> ==29752==    by 0x809A791: _mssql_fetch_batch (php_mssql.c:1140)
> ==29752==    by 0x809AF19: zif_mssql_query (php_mssql.c:1263)
> ==29752==    by 0x81C88DC: zend_do_fcall_common_helper_SPEC
> (zend_vm_execute.h:200)
> ==29752==    by 0x81CE2B2: ZEND_DO_FCALL_SPEC_CONST_HANDLER
> (zend_vm_execute.h:1679)
> ==29752==    by 0x81C842F: execute (zend_vm_execute.h:92)
> ==29752==    by 0x81A390F: zend_execute_scripts (zend.c:1134)
> ==29752==    by 0x8151090: php_execute_script (main.c:2005)
> ==29752==    by 0x821FEE5: main (php_cli.c:1140)
> ==29752==
> ==29752== Invalid write of size 1
> ==29752==    at 0x8099806: php_mssql_get_column_content_with_type
> (php_mssql.c:913)
> ==29752==    by 0x809A791: _mssql_fetch_batch (php_mssql.c:1140)
> ==29752==    by 0x809AF19: zif_mssql_query (php_mssql.c:1263)
> ==29752==    by 0x81C88DC: zend_do_fcall_common_helper_SPEC
> (zend_vm_execute.h:200)
> ==29752==    by 0x81CE2B2: ZEND_DO_FCALL_SPEC_CONST_HANDLER
> (zend_vm_execute.h:1679)
> ==29752==    by 0x81C842F: execute (zend_vm_execute.h:92)
> ==29752==    by 0x81A390F: zend_execute_scripts (zend.c:1134)
> ==29752==    by 0x8151090: php_execute_script (main.c:2005)
> ==29752==    by 0x821FEE5: main (php_cli.c:1140)
> ==29752==  Address 0x43c1712 is 1 bytes after a block of size 25 alloc'd
> ==29752==    at 0x4022AE8: malloc (vg_replace_malloc.c:207)
> ==29752==    by 0x8186640: _emalloc (zend_alloc.c:2280)
> ==29752==    by 0x8099794: php_mssql_get_column_content_with_type
> (php_mssql.c:911)
> ==29752==    by 0x809A791: _mssql_fetch_batch (php_mssql.c:1140)
> ==29752==    by 0x809AF19: zif_mssql_query (php_mssql.c:1263)
> ==29752==    by 0x81C88DC: zend_do_fcall_common_helper_SPEC
> (zend_vm_execute.h:200)
> ==29752==    by 0x81CE2B2: ZEND_DO_FCALL_SPEC_CONST_HANDLER
> (zend_vm_execute.h:1679)
> ==29752==    by 0x81C842F: execute (zend_vm_execute.h:92)
> ==29752==    by 0x81A390F: zend_execute_scripts (zend.c:1134)
> ==29752==    by 0x8151090: php_execute_script (main.c:2005)
> ==29752==    by 0x821FEE5: main (php_cli.c:1140)
> ==29752==
> ==29752== Invalid read of size 1
> ==29752==    at 0x81A1538: _zval_dtor_func (zend_variables.c:35)
> ==29752==    by 0x8096D01: _zval_dtor (zend_variables.h:35)
> ==29752==    by 0x8096B1A: _free_result (php_mssql.c:201)
> ==29752==    by 0x8096DA5: _free_mssql_result (php_mssql.c:236)
> ==29752==    by 0x81B195C: list_entry_destructor (zend_list.c:184)
> ==29752==    by 0x81AF21A: zend_hash_del_key_or_index (zend_hash.c:497)
> ==29752==    by 0x81B1614: _zend_list_delete (zend_list.c:58)
> ==29752==    by 0x809B0C8: zif_mssql_free_result (php_mssql.c:1309)
> ==29752==    by 0x81C88DC: zend_do_fcall_common_helper_SPEC
> (zend_vm_execute.h:200)
> ==29752==    by 0x81CE2B2: ZEND_DO_FCALL_SPEC_CONST_HANDLER
> (zend_vm_execute.h:1679)
> ==29752==    by 0x81C842F: execute (zend_vm_execute.h:92)
> ==29752==    by 0x81A390F: zend_execute_scripts (zend.c:1134)
> ==29752==  Address 0x43c1712 is 1 bytes after a block of size 25 alloc'd
> ==29752==    at 0x4022AE8: malloc (vg_replace_malloc.c:207)
> ==29752==    by 0x8186640: _emalloc (zend_alloc.c:2280)
> ==29752==    by 0x8099794: php_mssql_get_column_content_with_type
> (php_mssql.c:911)
> ==29752==    by 0x809A791: _mssql_fetch_batch (php_mssql.c:1140)
> ==29752==    by 0x809AF19: zif_mssql_query (php_mssql.c:1263)
> ==29752==    by 0x81C88DC: zend_do_fcall_common_helper_SPEC
> (zend_vm_execute.h:200)
> ==29752==    by 0x81CE2B2: ZEND_DO_FCALL_SPEC_CONST_HANDLER
> (zend_vm_execute.h:1679)
> ==29752==    by 0x81C842F: execute (zend_vm_execute.h:92)
> ==29752==    by 0x81A390F: zend_execute_scripts (zend.c:1134)
> ==29752==    by 0x8151090: php_execute_script (main.c:2005)
> ==29752==    by 0x821FEE5: main (php_cli.c:1140)
> ==29752==
> ==29752== ERROR SUMMARY: 40 errors from 4 contexts (suppressed: 45 from 2)
> ==29752== malloc/free: in use at exit: 156 bytes in 11 blocks.
> ==29752== malloc/free: 5,605 allocs, 5,594 frees, 1,535,300 bytes allocated.
> ==29752== For counts of detected errors, rerun with: -v
> ==29752== searching for pointers to 11 not-freed blocks.
> ==29752== checked 383,396 bytes.
> ==29752==
> ==29752==
> ==29752== 156 (36 direct, 120 indirect) bytes in 1 blocks are definitely lost
> in loss record 1 of 3
> ==29752==    at 0x4022AE8: malloc (vg_replace_malloc.c:207)
> ==29752==    by 0x41E13E2: (within /lib/tls/i686/cmov/libc-2.7.so)
> ==29752==    by 0x41E1C2D: __nss_database_lookup (in
> /lib/tls/i686/cmov/libc-2.7.so)
> ==29752==    by 0x4694FDB: ???
> ==29752==    by 0x469613C: ???
> ==29752==    by 0x418DD15: getpwuid_r (in /lib/tls/i686/cmov/libc-2.7.so)
> ==29752==    by 0x408E302: (within /usr/lib/libsybdb.so.5.0.0)
> ==29752==    by 0x4085660: (within /usr/lib/libsybdb.so.5.0.0)
> ==29752==    by 0x4085890: (within /usr/lib/libsybdb.so.5.0.0)
> ==29752==    by 0x40867D1: (within /usr/lib/libsybdb.so.5.0.0)
> ==29752==    by 0x406C073: tdsdbopen (in /usr/lib/libsybdb.so.5.0.0)
> ==29752==    by 0x8098B88: php_mssql_do_connect (php_mssql.c:661)
> ==29752==
> ==29752== LEAK SUMMARY:
> ==29752==    definitely lost: 36 bytes in 1 blocks.
> ==29752==    indirectly lost: 120 bytes in 10 blocks.
> ==29752==      possibly lost: 0 bytes in 0 blocks.
> ==29752==    still reachable: 0 bytes in 0 blocks.
> ==29752==         suppressed: 0 bytes in 0 blocks.
> 
> Still saying that some bytes where lost... Any ideas why this problem only
> shows on Ubuntu and not on Slackware?
> 
> /Krister Karlström
> 
> Derick Rethans wrote:
> 
> > On Wed, 15 Oct 2008, Krister Karlström wrote:
> > 
> > > run the same sample script with PHP 5.2.6 configured with --disable-all
> > > --enable-debug --with-mssql on the Ubuntu Hardy machine. I did exactly the
> > > same things on both the Slackware server and the Ubuntu, the output and
> > > expected result was though different:
> > > 
> > > Here's PHP:s output on Ubnuntu Hardy 8.0.4 with PHP 5.2.6:
> > 
> > [snip]
> > 
> > > It reports 10 memory leaks..? I'm also gonna run this though valgrind,
> > > need to
> > > install it on this machine first...
> > 
> > If you do, please export the following environment variable before you run
> > it with valgrind:
> > 
> > export USE_ZEND_ALLOC=0
> > 
> > that disables the zend memory manager, which means valgrind can see much
> > better what might go wrong. If it doesn't show anything then, switch it back
> > to "1" and try again.
> > 
> > regards,
> > Derick
> > 
> 
> 
> 

-- 
HEAD before 5_3!: http://tinyurl.com/6d2esb
http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to