From:             [EMAIL PROTECTED]
Operating system: CentOS 4
PHP version:      5CVS-2007-01-03 (CVS)
PHP Bug Type:     Sybase (dblib) related
Bug description:  Memory leak in sybase_query()

Description:
------------
Calling sybase_query() for a SELECT query that returns multiple rows
causes the memory limit to be hit or, in the case where the memory manager
isn't compiled in, memory usage to increase until the PHP process is
killed. I'm running Sybase ASE 15.0 on CentOS 4. The problem seems to
occur both with PHP_5_2 CVS and also PHP 4.4.4. PHP was compiled with
--with-sybase=/usr/local/sybase; /usr/local/sybase being the installation
directory for ASE on the box in question.

This looks quite similar to bug #39508, but that's using sybase-ct instead
of straight sybase.

Reproduce code:
---------------
<?php
$db = sybase_connect('LOCALHOST', 'sa', 'password') or die("Error
connecting to ASE.\n");
sybase_select_db('test', $db) or die("Error selecting database.\n");
if (sybase_query("CREATE TABLE phptest (a integer)", $db))
    echo "Table created.\n";
else
    echo "Error creating table.\n";
sybase_query("INSERT INTO phptest VALUES (1)", $db) or print("Error
inserting record.\n");
sybase_query("INSERT INTO phptest VALUES (2)", $db) or print("Error
inserting record.\n");
echo "Records inserted, attempting select...\n";
if (sybase_query('SELECT a FROM phptest WHERE a = 1', $db))
    echo "Single row select complete.\n";
else
    echo "Single row select failed.\n";
if (sybase_query('SELECT a FROM phptest WHERE a > 0', $db))
    echo "Multiple row select complete.\n";
else
    echo "Multiple row select failed.\n";
sybase_query('DROP TABLE phptest', $db) or print("Error dropping
table.\n");
sybase_close($db) or die("Error closing connection.\n");
?>

Expected result:
----------------
Table created.
Records inserted, attempting select...
Single row select complete.
Multiple row select complete.

Actual result:
--------------
Table created.
Records inserted, attempting select...
Single row select complete.

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to
allocate 3434496 bytes) in /tmp/test-sybase.php on line 15

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

Reply via email to