php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79310 ibase_fetch_* makes server crashes because of out of memory
Submitted: 2020-02-26 22:18 UTC Modified: 2021-03-31 11:42 UTC
From: nicolasv dot poubelle at gmail dot com Assigned:
Status: Suspended Package: InterBase related
PHP Version: 7.3.15 OS: debian 10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nicolasv dot poubelle at gmail dot com
New email:
PHP Version: OS:

 

 [2020-02-26 22:18 UTC] nicolasv dot poubelle at gmail dot com
Description:
------------
Hello everyone,

We have an old PHP application we want to upgrade from PHP 5.6 to PHP 7.3. 
The database is managed by a Firebird server.

We found a weird behaviour with PHP Interbase extension (PHP 7.3.15), and before qualify it as a bug, I wanted to know if other people had the same issue.

- ibase_connect to database
- create an array of ~200 queries (with INNER JOIN on some big tables)
- make a call to ibase_query
- make a call to ibase_fetch_* (no need to fetch all rows)

If you take care about the Firebird server memory usage, it will increase by ~5MB for each queries, without releasing memory. 

But if you make a call to ibase_free_result just after the call of ibase_fetch, memory is released on *server* side.

I tried to search in source code, problem seems to be about the call of isc_dsql_fetch, but I can't find any relevant difference between 5.6 source code and 7.3.
https://github.com/php/pecl-database-interbase/blob/master/ibase_query.c#L1476

Thanks by advance!

Test script:
---------------
ibase_connect('...');

$arr = array(/* queries on our firebird server */);
foreach ($arr as $query)
{
   $res = ibase_query($query);
   ibase_fetch_assoc($res);

   //if you make a call at ibase_free_result($res), memory on firebird server is released 
}

Expected result:
----------------
With PHP 5.6, the call of ibase_free_result isn't needed (memory usage is stable).


Actual result:
--------------
Memory usage on firebird server increases until server crashes:

In firebird.log :
SERVER/process_packet: out of memory
fbserver.exe: terminated abnormally (3221225477)

In PHP script :
Error reading data from the connection

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-26 22:21 UTC] nicolasv dot poubelle at gmail dot com
-: nicolas dot vannier at dunordausud dot fr +: nicolasv dot poubelle at gmail dot com
 [2020-02-26 22:21 UTC] nicolasv dot poubelle at gmail dot com
/
 [2021-03-31 11:42 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2021-03-31 11:42 UTC] cmb@php.net
The interbase extension is moved to PECL[1] as of PHP 7.4.0, and
is looking for a new maintainer.  Until a new maintainer is found,
I suspend this ticket.

Consider to use the bundled PDO_Firebird extension, or the
php-firebird package[2] instead.

[1] <https://pecl.php.net/package/interbase>
[2] <https://github.com/FirebirdSQL/php-firebird>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 03:01:28 2024 UTC