Bug #70869 [NEW]: mssql_fetch_batch tries to allocate 4GB memory

From: Date: Fri, 06 Nov 2015 09:51:12 +0000
Subject: Bug #70869 [NEW]: mssql_fetch_batch tries to allocate 4GB memory
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197074@lists.php.net to get a copy of this message
From:             m dot subotovic at gmail dot com
Operating system: Linux
PHP version:      5.4.45
Package:          MSSQL related
Bug Type:         Bug
Bug description:mssql_fetch_batch tries to allocate 4GB memory

Description:
------------
Fatal error: Allowed memory size of X bytes exhausted (tried to allocate
4294967296 bytes)

The error above is being shown when using mssql_fetch_batch on two
different connections. Look at the test script example.

Test script:
---------------
<?php

function fetchAssoc($link)
{
    $res = mssql_fetch_assoc($link);

    if ($res === false) {
        if (mssql_fetch_batch($link) > 0) {
            $res = mssql_fetch_assoc($link);
        }
    }
    return $res;
}

$link1 = mssql_connect('host', 'user', 'pwd');
mssql_select_db('db', $link1);

$link2 = mssql_connect('host', 'user', 'pwd');
mssql_select_db('db', $link2);

$result1 = mssql_query("SELECT TOP 2 * FROM table", $link1, 1);

while ($row1 = fetchAssoc($result1)) {
    echo "Row from 1 result\n";

    $result2 = mssql_query("SELECT TOP 2 * FROM table2", $link2);
    while ($row2 = fetchAssoc($result2)) {
        echo "Row from 2 result\n";
    }
}

echo "Done";

Expected result:
----------------
Row from 1 result
Row from 2 result
Row from 2 result
Row from 1 result
Row from 2 result
Row from 2 result
Done

Actual result:
--------------
Row from 1 result
Row from 2 result
Row from 2 result

Fatal error: Allowed memory size of X bytes exhausted (tried to allocate
4294967296 bytes)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=70869&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70869&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70869&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70869&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70869&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70869&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70869&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70869&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70869&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70869&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70869&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70869&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70869&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70869&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70869&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70869&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70869&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70869&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70869&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70869&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70869&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#197074) next »