From:             ipa at beta dot lt
Operating system: Linux/FreeBSD
PHP version:      4.3.4
PHP Bug Type:     Sockets related
Bug description:  Memory leaking with sockets

Description:
------------
Sockets' socket_read() left 8 bytes in memory.

Example configure:
'./configure' '--enable-versioning' '--enable-memory-limit'
'--with-layout=GNU' '--with-zlib-dir=/usr' '--disable-all'
'--with-regex=php' '--disable-cli' '--enable-ctype'
'--with-dom=/usr/local' '--with-gd' '--enable-gd-native-ttf'
'--enable-gd-jis-conv' '--with-freetype-dir=/usr/local'
'--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local'
'--with-xpm-dir=/usr/local' '--with-mysql=/usr/local' '--enable-overload'
'--with-pcre-regex=yes' '--enable-posix' '--enable-session'
'--enable-sockets' '--enable-tokenizer' '--with-expat-dir=/usr/local'
'--enable-xml' '--with-zlib=yes' '--with-apxs2=/usr/local/sbin/apxs'
'--with-imap=/usr/local' '--with-imap-ssl=/usr/local'
'--prefix=/usr/local' 'i386-portbld-freebsd4.8'

but reproducable on linux too.



Reproduce code:
---------------
function foo(){
        $socket = socket_create (AF_INET, SOCK_STREAM, 0); 
        $result = socket_connect ($socket, gethostbyname ('www.example.com'),
80); 
        $in = "HEAD / HTTP/1.0\r\n\r\n";
        
        socket_write ($socket, $in, strlen ($in)); 
        while ($out = socket_read ($socket, 2048)) { /* .. */ }
        
        socket_close ($socket);
}

foo();
echo memory_get_usage() . "<br>";
foo();
echo memory_get_usage() . "<br>";
foo();
echo memory_get_usage() . "<br>";


Expected result:
----------------
xxxxx bytes.
xxxxx bytes.
xxxxx bytes.

Actual result:
--------------
xxxxx bytes.
xxxxx + 8 bytes.
xxxxx + 16 bytes.
...
xxxxx + (n * 8) bytes.

-- 
Edit bug report at http://bugs.php.net/?id=26475&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26475&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26475&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26475&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26475&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26475&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26475&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26475&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26475&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26475&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26475&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26475&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26475&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26475&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26475&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26475&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26475&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26475&r=float

Reply via email to