Multiple connections to Interbase with php >= 7.0 are not allowed

Bug #1578600 reported by NetVicious on 2016-05-05
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
php7.0 (Ubuntu)
Medium
Unassigned

Bug Description

# lsb_release -rd
Description: Ubuntu 16.04 LTS
Release: 16.04

-------------------

# apt-cache policy php7.0-interbase
php7.0-interbase:
  Instalados: 7.0.4-7ubuntu2
  Candidato: 7.0.4-7ubuntu2
  Tabla de versión:
 *** 7.0.4-7ubuntu2 500
        500 http://es.archive.ubuntu.com/ubuntu xenial/universe i386 Packages
        100 /var/lib/dpkg/status

-------------------

It seems PHP 7 changed a bit the way to work with the Interbase module.

Same code on PHP 5.6 works flawlessly.

If you have one open link to an Interbase/Firebird database and you open **another** one to the same database the first link it's closed.

One example of code can be:

    $conx = ibase_pconnect(DB_HOST . ":" . DB_NAME,DB_USER,DB_PWD,DB_CHARACTER) or die(ibase_errcode() . ' ' . ibase_errmsg());

    $conx2 = ibase_pconnect(DB_HOST . ":" . DB_NAME,DB_USER,DB_PWD,DB_CHARACTER) or die(ibase_errcode() . ' ' . ibase_errmsg());

    $sql = 'SELECT something from somewhere';

    $query = ibase_query($conx, $sql);

    while ($row = ibase_fetch_assoc($query)) {
        echo $row['something'];
    }

DB_xxx are defined variables with the users, password, ..... of the database.

The result it's the same if instead of **ibase_pconnect** we write **ibase_connect**

If you run that code you won't get nothing and on the apache log you will see something like:

    supplied resource is not a valid Firebird/InterBase link resource in ....

    ibase_fetch_assoc(): Dynamic SQL Error SQL error code = -504 Invalid cursor reference Cursor is not open ....

If we remove the line with the $conx2 all will work perfectly.

On my php.ini I have this (exactly the same than on PHP 5.6):

    ibase.allow_persistent = 1

    ; Maximum number of persistent links. -1 means no limit.
    ibase.max_persistent = -1

    ; Maximum number of links (persistent + non-persistent). -1 means no limit.
    ibase.max_links = -1

Interbase module for php7 has a new option which it's generating this problem ?

Nish Aravamudan (nacc) wrote :
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in php7.0 (Ubuntu):
status: New → Confirmed
Dupre (dupre) wrote :

Affected by this bug too.

User NikiC on StackOverflow writed this:

"In particular, I don't think this line is correct: lxr.php.net/xref/PHP_MASTER/ext/interbase/interbase.c#943 This zend_list_close should probably be a zend_list_delete, otherwise it will simply always destroy the resource."

Please, somebody help with this bug. Thanks in advance.

Nish Aravamudan (nacc) wrote :

@Dupre, is it possible to provide a link to the stackoverflow discussion? I can try building a version in a PPA to test, but the right fix currently is to get upstream PHP fixed first, if we can (and it will go through their CI process then).

NetVicious (netvicious) wrote :

There it's no more information on stackoverflow.
Here's the link: http://stackoverflow.com/questions/37049534/multiple-connections-to-interbase-with-php-7-0

Nish Aravamudan (nacc) wrote :

As part of bug 1569609, I have created a microrelease-update test version at: https://launchpad.net/~nacc/+archive/ubuntu/lp1569609, and have built a version of that PHP7.0 with the potential fix for this bug (as per SO) at: https://launchpad.net/~nacc/+archive/ubuntu/lp1578600.

If anyone affected could also test that version (7.0.8-0ubuntu1~lp1578600), that would be very helpful!

Dupre (dupre) wrote :

The test version LP1578600 solves this bug. I have no more this error with this test update.

Thank you very much for your help!!! Good job!!!

On Jun 27, 2016 23:15, "Dupre" <email address hidden> wrote:
>
> The test version LP1578600 solves this bug. I have no more this error
> with this test update.
>
> Thank you very much for your help!!! Good job!!!

Would you be able to verify that the version from
https://launchpad.net/~nacc/+archive/ubuntu/lp1569609 still exhibits the
problem? This will help ensure it wasn't just fixed by the new upstream.

Thanks for testing so quickly!

-Nish

Version from repository ppa:nacc/lp1569609 still contains bug.

After:
sudo add-apt-repository ppa:nacc/lp1569609
sudo apt-get update
sudo apt-get upgrade

I get the same error messages again.

NetVicious (netvicious) wrote :

I confirm too that lp1569609 still contains bug, and lp1578600 FIXES perfectly this bug.

Good job and thanks.

NetVicious (netvicious) on 2016-06-28
description: updated
Nish Aravamudan (nacc) wrote :

@Dupre & @NetVicious: Great, thanks to you both for this quick testing. I simply backported NikiC's suggestion from SO. I will update the PHP bug, as I think we'd rather it get fixed appropriately upstream (and they will presumably add a testcase).

-Nish

NetVicious (netvicious) wrote :

Hi Nish,

So we had the solution near two months in front our face.

I saw your comment on php bugtracker. There we don't have any developer assigned so why you don't create a patch within the tool?

It seems you're the maintainer of the php package for the Ubuntu distro, so. We will have a fixed php package in some days? or we need to wait for the upstream fix?

Dupre (dupre) wrote :

Thanks you Nish for working in this bug.

As soon as the fix is available I'll start migrating to php 7 some of my applications.

Good job!!!

NetVicious (netvicious) wrote :

Hi dupre,

I have some applications running with php7+firebird and this one was the only bug I found. I fixed it temporary using a static var for the php connection to the database in my DB library.

Hasta luego ;-)

On 28.06.2016 [16:07:20 -0000], NetVicious wrote:
> Hi Nish,
>
> So we had the solution near two months in front our face.

So it seems :)

> I saw your comment on php bugtracker. There we don't have any developer
> assigned so why you don't create a patch within the tool?

I will send a PR in github (what I've done in the past). I'm not really
a PHP developer, so I'm not sure if it will be accepted as-is (and don't
know the full consequences of the change, or if more fixes are needed),
which is why I'd prefer the PHP developers figure out the fix.

> It seems you're the maintainer of the php package for the Ubuntu
> distro, so. We will have a fixed php package in some days? or we need
> to wait for the upstream fix?

I'd like to wait to see if upstream responds, at least. If not, I'll see
what I can do.

Hi NetVicious,

Thanks for your help. I have this problem in all my apps (they have common libraries and classes). I think I'll wait for the fix.

Moltes gracies ;)

NetVicious (netvicious) wrote :

The upstream bug had a comment about other users with the same problem using ADOdb. I posted yesterday a note saying the bug was found and fixed.

https://github.com/ADOdb/ADOdb/issues/231

Nish Aravamudan (nacc) wrote :

@netvicious, thanks for tying up those threads! I have also pinged Nikola (NikiC) offline to see if they can help get that bug fixed upstream.

NetVicious (netvicious) wrote :

Hi! This patch was relesed on the ubuntu updates ?

In the upstream bugtracker seems no one it's taking attention on it.

I'm using the libapache2-mod-php7.0 (7.0.13-0ubuntu0.16.04.1) on Ubuntu 16.04.1 LTS and the bug it's there yet.

Nish, do you have any newer update on the progress on this?

NetVicious (netvicious) wrote :

Interbase module seems to be abandoned. All the developers which appear on phpinfo() related with the Interbase/firebird module are not active developers of php looking at their Linkedin accounts.

So obviously this bug won't be fixed because there it's no active developer in charge of the interbase/firebird module.

I think the module was ported to PHP 7.0 by someon which doesn't know the previous module and that's why it has bugs like this one.

Nish Aravamudan (nacc) wrote :

Thank you for working hard on this upstream and here. I'm sorry for the state of the Interbase module, but I'm not sure there are any safe options for Ubuntu to proceed with without at least a more complete upstream fix (that doesn't regress the tests in the code).

NetVicious (netvicious) wrote :

Hi Nish!
As you can see the bug was reported for php 7.0. We tested it on 7.1 and 7.2 and it's yet there.

That's why I think it's not a problem of the Ubuntu package. And I think when Ubuntu takes a new major version, like 7.1 and 7.2 was, you should take the complete upstream instead of doing all the new changes of that version on the old code, isn't it?

No one has assigned it on the official PHP bugtracker (https://bugs.php.net/bug.php?id=72175) and at this moment it cannot be fixed because no one it's taking care of the interbase/firebird module on the PHP developers team.

Nish Aravamudan (nacc) wrote :

> That's why I think it's not a problem of the Ubuntu package. And I think when Ubuntu takes a new
> major version, like 7.1 and 7.2 was, you should take the complete upstream instead of doing all the
> new changes of that version on the old code, isn't it?

Right, we (well, Debian originally) take the upstream as it is, then patch it appropriately, with bugfixes and some documentation/branding/building fixes.

NetVicious (netvicious) wrote :

Ok, so that confirms the bug was not patched on 7.1 and 7.2 upstream. And I think it should not be patched on 7.3 too.

Can you change the bugreport to assign it to 7.2 too.

Robie Basak (racb) on 2018-11-29
summary: - Multiple connections to Interbase with php 7.0 are not allowed
+ Multiple connections to Interbase with php >= 7.0 are not allowed
Changed in php7.0 (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → Medium
NetVicious (netvicious) wrote :

Hi! upstream bug has been closed and semi-fixed.
I don't know if the fix was send to 7.3 branch or older.

It is mentioned to be fixed in 7.2 and later.
But only recently, so my expectation would be that with the next minor release being pushed as security update anything >= Ubuntu 18.04 will be fixed.
That will be php 7.2.17 or later then (depending when/which CVEs are in it)

But as you called it "semi-fixed" it will only cover what was done upstream.

NetVicious (netvicious) wrote :

Ok thanks, I will test it on the next php7.2 update.

NetVicious (netvicious) wrote :

Seems to be fixed on Ubuntu 18.04.2 LTS in php package 7.2.19-0ubuntu0.18.04.1.

It was fixed on the upstream package time ago.

https://bugs.php.net/bug.php?id=72175

The bug can be closed now.

Thanks to all.

Changed in php7.0 (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.