From:             poletto at jeuxvideo dot com
Operating system: Linux 2.4
PHP version:      5.2.5
PHP Bug Type:     PDO related
Bug description:  Memory errors in PDO constructor

Description:
------------
There were some crashes with 5.2.4 when using pdo, so i've tried out 5.2.5
that seems to have fixed this crashes.
Just to make sure there was no problem, i've tried to valgrind the command
line program on a simple script using pdo.
There are a few memory errors (this can make crashes occur).
Note that the leaks are due to the kernel 2.4 threads (so, ignore them).


Reproduce code:
---------------
<?php

$dbh = new PDO('mysql:host=host;dbname=db', 'user', 'pass',
array(PDO::ATTR_PERSISTENT => true));

?>


Expected result:
----------------
No memory errors

Actual result:
--------------
Valgrind's output

> valgrind -q --leak-check=full --show-reachable=yes
/usr/local/src/php-5.2.5/sapi/cli/php test_pdo.php
==10313== Invalid read of size 4
==10313==    at 0x40B29BD: my_strdup (in
/usr/local/MySQL-5.0.45/lib/libmysqlclient.so.15)
==10313==    by 0x40D61D5: mysql_real_connect (in
/usr/local/MySQL-5.0.45/lib/libmysqlclient.so.15)
==10313==    by 0x80F384C: pdo_mysql_handle_factory (mysql_driver.c:553)
==10313==    by 0x80EAC76: zim_PDO_dbh_constructor (pdo_dbh.c:372)
==10313==    by 0x8237479: zend_do_fcall_common_helper_SPEC
(zend_vm_execute.h:200)
==10313==    by 0x8236D44: execute (zend_vm_execute.h:92)
==10313==    by 0x8220018: zend_execute_scripts (zend.c:1134)
==10313==    by 0x81ED74F: php_execute_script (main.c:2004)
==10313==    by 0x827A9B1: main (php_cli.c:1140)
==10313==  Address 0x471F388 is 8 bytes inside a block of size 9 alloc'd
==10313==    at 0x401A826: malloc (vg_replace_malloc.c:149)
==10313==    by 0x449A33F: strdup (in /lib/i686/libc-2.3.2.so)
==10313==    by 0x80EAB51: zim_PDO_dbh_constructor (pdo_dbh.c:358)
==10313==    by 0x8237479: zend_do_fcall_common_helper_SPEC
(zend_vm_execute.h:200)
==10313==    by 0x8236D44: execute (zend_vm_execute.h:92)
==10313==    by 0x8220018: zend_execute_scripts (zend.c:1134)
==10313==    by 0x81ED74F: php_execute_script (main.c:2004)
==10313==    by 0x827A9B1: main (php_cli.c:1140)
==10313==
==10313== Invalid read of size 4
==10313==    at 0x40B1BC2: scramble (in
/usr/local/MySQL-5.0.45/lib/libmysqlclient.so.15)
==10313==    by 0x40D654D: mysql_real_connect (in
/usr/local/MySQL-5.0.45/lib/libmysqlclient.so.15)
==10313==    by 0x80F384C: pdo_mysql_handle_factory (mysql_driver.c:553)
==10313==    by 0x80EAC76: zim_PDO_dbh_constructor (pdo_dbh.c:372)
==10313==    by 0x8237479: zend_do_fcall_common_helper_SPEC
(zend_vm_execute.h:200)
==10313==    by 0x8236D44: execute (zend_vm_execute.h:92)
==10313==    by 0x8220018: zend_execute_scripts (zend.c:1134)
==10313==    by 0x81ED74F: php_execute_script (main.c:2004)
==10313==    by 0x827A9B1: main (php_cli.c:1140)
==10313==  Address 0x471F388 is 8 bytes inside a block of size 9 alloc'd
==10313==    at 0x401A826: malloc (vg_replace_malloc.c:149)
==10313==    by 0x449A33F: strdup (in /lib/i686/libc-2.3.2.so)
==10313==    by 0x80EAB51: zim_PDO_dbh_constructor (pdo_dbh.c:358)
==10313==    by 0x8237479: zend_do_fcall_common_helper_SPEC
(zend_vm_execute.h:200)
==10313==    by 0x8236D44: execute (zend_vm_execute.h:92)
==10313==    by 0x8220018: zend_execute_scripts (zend.c:1134)
==10313==    by 0x81ED74F: php_execute_script (main.c:2004)
==10313==    by 0x827A9B1: main (php_cli.c:1140)
==10313==
==10313== Invalid read of size 4
==10313==    at 0x40B15E1: scramble_323 (in
/usr/local/MySQL-5.0.45/lib/libmysqlclient.so.15)
==10313==    by 0x40D66F3: mysql_real_connect (in
/usr/local/MySQL-5.0.45/lib/libmysqlclient.so.15)
==10313==    by 0x80F384C: pdo_mysql_handle_factory (mysql_driver.c:553)
==10313==    by 0x80EAC76: zim_PDO_dbh_constructor (pdo_dbh.c:372)
==10313==    by 0x8237479: zend_do_fcall_common_helper_SPEC
(zend_vm_execute.h:200)
==10313==    by 0x8236D44: execute (zend_vm_execute.h:92)
==10313==    by 0x8220018: zend_execute_scripts (zend.c:1134)
==10313==    by 0x81ED74F: php_execute_script (main.c:2004)
==10313==    by 0x827A9B1: main (php_cli.c:1140)
==10313==  Address 0x471F388 is 8 bytes inside a block of size 9 alloc'd
==10313==    at 0x401A826: malloc (vg_replace_malloc.c:149)
==10313==    by 0x449A33F: strdup (in /lib/i686/libc-2.3.2.so)
==10313==    by 0x80EAB51: zim_PDO_dbh_constructor (pdo_dbh.c:358)
==10313==    by 0x8237479: zend_do_fcall_common_helper_SPEC
(zend_vm_execute.h:200)
==10313==    by 0x8236D44: execute (zend_vm_execute.h:92)
==10313==    by 0x8220018: zend_execute_scripts (zend.c:1134)
==10313==    by 0x81ED74F: php_execute_script (main.c:2004)
==10313==    by 0x827A9B1: main (php_cli.c:1140)
==10313==
==10313==
==10313== 28 bytes in 1 blocks are still reachable in loss record 1 of 4
==10313==    at 0x401A826: malloc (vg_replace_malloc.c:149)
==10313==    by 0x400B875: _dl_map_object_deps (in /lib/ld-2.3.2.so)
==10313==    by 0x4532DBA: dl_open_worker (in /lib/i686/libc-2.3.2.so)
==10313==    by 0x400C895: _dl_catch_error (in /lib/ld-2.3.2.so)
==10313==    by 0x45329AE: _dl_open (in /lib/i686/libc-2.3.2.so)
==10313==    by 0x45347C7: do_dlopen (in /lib/i686/libc-2.3.2.so)
==10313==    by 0x400C895: _dl_catch_error (in /lib/ld-2.3.2.so)
==10313==    by 0x453468D: __libc_dlopen_mode (in
/lib/i686/libc-2.3.2.so)
==10313==    by 0x4512C30: __nss_lookup_function (in
/lib/i686/libc-2.3.2.so)
==10313==    by 0x451287A: __nss_lookup (in /lib/i686/libc-2.3.2.so)
==10313==    by 0x4514616: __nss_services_lookup (in
/lib/i686/libc-2.3.2.so)
==10313==    by 0x4517C61: getservbyname_r@@GLIBC_2.1.2 (in
/lib/i686/libc-2.3.2.so)
==10313==
==10313==
==10313== 68 bytes in 1 blocks are possibly lost in loss record 2 of 4
==10313==    at 0x401BC54: calloc (vg_replace_malloc.c:279)
==10313==    by 0x400EBE8: _dl_allocate_tls_storage (in /lib/ld-2.3.2.so)
==10313==    by 0x400EDD8: _dl_allocate_tls (in /lib/ld-2.3.2.so)
==10313==    by 0x43D756B: __pthread_initialize_minimal (in
/lib/i686/libpthread-0.10.so)
==10313==    by 0x43D4205: (within /lib/i686/libpthread-0.10.so)
==10313==    by 0x43D3C52: (within /lib/i686/libpthread-0.10.so)
==10313==    by 0x400CC51: _dl_init (in /lib/ld-2.3.2.so)
==10313==    by 0x4000C5C: (within /lib/ld-2.3.2.so)
==10313==
==10313==
==10313== 520 bytes in 1 blocks are still reachable in loss record 3 of 4
==10313==    at 0x401BC54: calloc (vg_replace_malloc.c:279)
==10313==    by 0x400EAF7: _dl_tls_setup (in /lib/ld-2.3.2.so)
==10313==    by 0x43D755C: __pthread_initialize_minimal (in
/lib/i686/libpthread-0.10.so)
==10313==    by 0x43D4205: (within /lib/i686/libpthread-0.10.so)
==10313==    by 0x43D3C52: (within /lib/i686/libpthread-0.10.so)
==10313==    by 0x400CC51: _dl_init (in /lib/ld-2.3.2.so)
==10313==    by 0x4000C5C: (within /lib/ld-2.3.2.so)
==10313==
==10313==
==10313== 1,288 bytes in 1 blocks are possibly lost in loss record 4 of 4
==10313==    at 0x401BE0C: memalign (vg_replace_malloc.c:332)
==10313==    by 0x400EBA1: _dl_allocate_tls_storage (in /lib/ld-2.3.2.so)
==10313==    by 0x400EDD8: _dl_allocate_tls (in /lib/ld-2.3.2.so)
==10313==    by 0x43D756B: __pthread_initialize_minimal (in
/lib/i686/libpthread-0.10.so)
==10313==    by 0x43D4205: (within /lib/i686/libpthread-0.10.so)
==10313==    by 0x43D3C52: (within /lib/i686/libpthread-0.10.so)
==10313==    by 0x400CC51: _dl_init (in /lib/ld-2.3.2.so)
==10313==    by 0x4000C5C: (within /lib/ld-2.3.2.so)


-- 
Edit bug report at http://bugs.php.net/?id=43371&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43371&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43371&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43371&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43371&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43371&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43371&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43371&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43371&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43371&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43371&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43371&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43371&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43371&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43371&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43371&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43371&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43371&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43371&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43371&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43371&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43371&r=mysqlcfg

Reply via email to