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: 2020-02-26 22:21 UTC
From: nicolasv dot poubelle at gmail dot com Assigned:
Status: Open Package: InterBase related
PHP Version: 7.3.15 OS: debian 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
49 - 41 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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
/
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Mar 08 10:01:23 2021 UTC