Bug 148269 - PHP4/5 : odbc_exec() & odbc_do() broken when running within a Apache2 process
Summary: PHP4/5 : odbc_exec() & odbc_do() broken when running within a Apache2 process
Status: RESOLVED WONTFIX
Alias: None
Product: SUSE LINUX 10.0
Classification: openSUSE
Component: Other (show other bugs)
Version: Final
Hardware: i586 SuSE Linux 10.0
: P5 - None : Normal
Target Milestone: ---
Assignee: Petr Ostadal
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-05 08:32 UTC by Francois Chenier
Modified: 2006-04-15 20:36 UTC (History)
0 users

See Also:
Found By: Customer
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Francois Chenier 2006-02-05 08:32:16 UTC
For a mysterious reason, PHP4/5 odbc_exec() & odbc_do() commands always crash when they are processed within a Apache web server but works fine if they are running directly from a command line (e.g. php5 <scriptname>).

I suspect something wrong in the php5-odbc-5.0.4-9 RPM package because if I replace the 'odbc' file (the shared object file bridging unixODBC to PHP) with one from the package with the same name in Linux Fedora Core 4, it's working better but fails ultimately for the same reason (when some garbage collector routine did not have time to clean apache2handler memory).

Other evidence pointing in the same directions ...
... both unixODBC & knoda (using an ODBC connection of coarse) works fine together on my system,
... it seems bot to be a PHP/Apache related bug because all my other PHP pages run fine,
... PHP web pages using the direct MySQL-PHP bridge (php5-mysql-5.0.4-9) are running fine as well,
... if I replace in my script the faulty do/exec command by odbc_execute(), PHP won't crash (but don't return anything of coarse).

The errors in the Apache2 server log file are :

[Sun Feb 05 16:59:15 2006] [notice] Apache/2.0.54 (Linux/SUSE) configured -- resuming normal operations
[client 127.0.0.2] PHP Fatal error:  Allowed memory size of 8388608 bytes exhausted (tried to allocate -2145741639 bytes) in /home/Apache/YellowPgs2.php on line XXX
Allowed memory size of 8388608 bytes exhausted (tried to allocate 256 bytes)
[client 127.0.0.2] PHP Fatal error:  Allowed memory size of 8388608 bytes exhausted (tried to allocate -2145741639 bytes) in /home/Apache/YellowPgs2.php on line XXX
Allowed memory size of 8388608 bytes exhausted (tried to allocate 256 bytes)

I noticed this bug with following revelant software installed ...
+ unixODBC-2.2.11 (any ODBC drivers)
+ php5-5.0.4-9.6
+ php5-odbc-5.0.4-9
+ apache2-mod_php5-5.0.4-9.6
+ apache-2.0.54-10

This problem is worse with PHP 4.4.0 because the php4-unixODBC package is broken too (this time - unable to connect because Apache2 server fails to load the 'odbc.so' shared library).

Francois Chenier, eng
Australia
Comment 1 Cristian Rodríguez 2006-02-06 15:59:24 UTC
(In reply to comment #0)
> For a mysterious reason, PHP4/5 odbc_exec() & odbc_do() commands always crash
> when they are processed within a Apache web server but works fine if they are
> running directly from a command line (e.g. php5 <scriptname>).

do you have a working test case ??

> 
> I suspect something wrong in the php5-odbc-5.0.4-9 RPM package because if I
> replace the 'odbc' file (the shared object file bridging unixODBC to PHP) with
> one from the package with the same name in Linux Fedora Core 4, it's working
> better but fails ultimately for the same reason (when some garbage collector
> routine did not have time to clean apache2handler memory).

MMM... 

> The errors in the Apache2 server log file are :
> 
> [Sun Feb 05 16:59:15 2006] [notice] Apache/2.0.54 (Linux/SUSE) configured --
> resuming normal operations
> [client 127.0.0.2] PHP Fatal error:  Allowed memory size of 8388608 bytes
> exhausted (tried to allocate -2145741639 bytes) in /home/Apache/YellowPgs2.php
> on line XXX
> Allowed memory size of 8388608 bytes exhausted (tried to allocate 256 bytes)
> [client 127.0.0.2] PHP Fatal error:  Allowed memory size of 8388608 bytes
> exhausted (tried to allocate -2145741639 bytes) in /home/Apache/YellowPgs2.php
> on line XXX
> Allowed memory size of 8388608 bytes exhausted (tried to allocate 256 bytes)

this means you need to raise your memory limit setting in php.ini

something like memory_limit = 32M should do the trick.


> This problem is worse with PHP 4.4.0 because the php4-unixODBC package is
> broken too (this time - unable to connect because Apache2 server fails to load
> the 'odbc.so' shared library).

that's another different problem, maybe Petr can give you a response, I'll not spend my time debugging PHP4 packages anymore.
Comment 2 Francois Chenier 2006-02-06 23:35:20 UTC
> do you have a working test case ??

Nothing fancy but just this simple case will show the problem.

*****YellowPgs3.php*****
<html>
<head>
<title>Bug 148269</title>
</head>
<body>
<form action="YellowPgs3.php" name="querybox1" method="POST">
  <input type="image" src="Images/Go.gif" name="ClickMe"></td>
</form>
<?php
  // Connect to the database
  $objConn = odbc_connect("Java", "<username>", "<password>");

  if ($objConn)
    {
      // SQL Query
      $Query = "SELECT Compagnie FROM AsiaDB WHERE Reference LIKE '%ISO%'";
      $objRS = odbc_exec($objConn, $Query);
      while(odbc_fetch_row($objRS))
        printf("<p>%s</p>\n",odbc_result($objRS,1));

      // Clean-up
      odbc_free_result($objRS);
      odbc_close($objConn);
    }
?>
</body>

Working case : php5 -q YellowPgs3.php > YellowPgs3.htm

Buggy case : Unable to run this page from my Apache2 web server (with error as explaned above). If you replace the line with odbc_exec() by an odbc_execute() call the script run normally (with just some normal warnings in log file).

>> I suspect something wrong in the php5-odbc-5.0.4-9 RPM package because if I
>> replace the 'odbc' file (the shared object file bridging unixODBC to PHP) with
>> one from the package with the same name in Linux Fedora Core 4, it's working
>> better but fails ultimately for the same reason (when some garbage collector
>> routine did not have time to clean apache2handler memory).
>
>MMM...

It's just an observation & I don't think you must put a lot emphasis on this. 
Some imcompatibilities between FC4's 'odbc' file & SuSE's 'libphp5.so' are possible because they were not built at the same time with the same tools.

> this means you need to raise your memory limit setting in php.ini
>
> something like memory_limit = 32M should do the trick

I tried 64M before reporting this bug. No luck! (and it's not logical to take so much memory - the text dump of the entire database file takes only 28.4K!)

> that's another different problem, maybe Petr can give you a response, I'll not
> spend my time debugging PHP4 packages anymore.

It's fine & I have a idea of what is the problem. The link between 'odbc.so' (php4-unixODBC pkg) and 'libodbc.so' (unixODBC pkg) seems broken in this distro.
Comment 3 Cristian Rodríguez 2006-02-07 00:25:59 UTC
PEtr: can you reproduce this issue..??? 
I have none of the databases who the odbc driver supports.

BTW.. if I remember correctly..this  problem was reported before....

Comment 4 Francois Chenier 2006-02-07 01:13:39 UTC
PEtr: Take care if you are using SQI Text ODBC Driver in unixODBC-2.2.11-2.i586.rpm package. It's buggy but you should have access to an updated version of this package. See https://bugzilla.novell.com/show_bug.cgi?id=146507 for details.

I have also this problem with MySQL ODBC driver (MySQL-unixODBC-3.51.11-2.i586.rpm).
Comment 5 Petr Ostadal 2006-02-07 10:32:48 UTC
Francois, did you test it with new php from OpenSuSE? (or from ftp://ftp.suse.com/pub/projects/apache/php5 ).
Comment 6 Francois Chenier 2006-02-07 11:21:37 UTC
Presently I have in my laptop PHP5 upgraded from YOU using Aussie mirror:
ftp://ftp.iinet.net.au/pub/suse/Suse/i386/update/10.0/rpm/i586
for files
  php5-5.0.4-9.6.i586.rpm
  apache2-mod_php5-5.0.4-9.6.i586.rpm
and I manually installed (rpm -i blabla...) files
  php5-odbc-5.0.4.9-i586.rpm
  php5-mysql-5.0.4.9-i586.rpm
downloaded from ftp://ftp.jaist.ac.jp/pub/Linux/openSUSE/distribution/SL-OSS-stable/inst-source/suse/i586/

If you download & install all files from OpenSuSE ftp mirror, the final result will be the same as mine. I tried both ways.

Comment 7 Petr Ostadal 2006-02-07 12:05:03 UTC
Ok, and could you please test it with new php from ftp in comment #5 ?
Comment 8 Francois Chenier 2006-02-07 12:36:14 UTC
Petr:

If you can tell me where I can find apache_mmn_20051115, yes. I have Apache 2.0.54 installed (standard version & up-to-date) on my laptop.

belgix@edinburgh:~/Desktop> rpm --test -U --nosignature apache2-mod_php5-5.1.2-2.1.20060126.i586.rpm
error: Failed dependencies:
        apache_mmn_20051115 is needed by apache2-mod_php5-5.1.2-2.1.20060126
        php5 = 5.1.2 is needed by apache2-mod_php5-5.1.2-2.1.20060126
Comment 9 Petr Ostadal 2006-02-07 12:52:35 UTC
you should update from same ftp all packages from following list ( ftp://ftp.suse.com/pub/projects/apache/php5/.needed_updates ):
apache2
ccache
libapr1
libapr1-devel
libapr-util1
libapr-util1-devel
tidy

apache_mmn_20051115 you find in ftp://ftp.suse.com/pub/projects/apache/apache2/10.0-i386/apache2-2.2.0-2.1.20060118.i586.rpm
Comment 10 Francois Chenier 2006-02-07 13:02:56 UTC
Petr: I will do it tomorrow morning. It's late here (23:30).

Have a nice day!
Comment 11 Francois Chenier 2006-02-08 00:56:00 UTC
Petr: I upgraded my system this morning (not w/o problems because I initially tried to upgrade using my original Apache 2.0.48 configuration files) but now with
  apache2-2.2.0-2.1.20060118.i586.rpm
  apache2-prefork-2.2.0-2.1.20060118.i586.rpm
  libapr-util1-1.2.2-1.1.i586.rpm
  libapr1-1.2.2-1.1.i586.rpm
  php5-5.1.2-2.1.20060126.i586.rpm
  php5-odbc-5.1.2-2.1.20060126.i586.rpm
  php5-mysql-5.1.2-2.1.20060126.i586.rpm
and
  unixODBC-2.2.11 (working fine with knoda or using PHP5 from command line)

the result is not very different except for a little variant. When I'm loading the faulty page from Konqueror, I no  receive the message "Connection broken" even if the error in /var/log/apache2/error_msg is the same (memory allocation - 8M exhausted). All web pages containing PHP code not referring to odbc_exec & odbc_do function work fine as previously.
Comment 12 Cristian Rodríguez 2006-02-08 01:12:08 UTC
Francois: to what database tyoe ar you trying to connect ??


Petr FYI: no relavant changes in PHP CVS odbc driver since latest package build. 
Comment 13 Francois Chenier 2006-02-08 07:47:04 UTC
Cristian: Something new. When I wrote message #11 I tested only the problem with the SQI Text ODBC driver (included in unixODBC package) who is still not working (with Apache only). Now with Apache 2.2 and PHP 5.1.2 the MySQL ODBC driver seems to works much better (I was not working at all before that). By working better, I'm not meaning working perfect because sometimes (10%-15%) when I reload the page, the error is still there (leading to put Apache server in an unstable state - restart needed).

Last week I found a bug in the unixODBC package. According to Michal Marek the bug is now fixed (see https://bugzilla.novell.com/show_bug.cgi?id=146507) but SuSE has not released the updated version yet (at 06-02-08 19:15 UTC).

From now & to be sure where to go, can you tell me where I can find this updated version ? Package version should be greater than unixODBC-2.2.11-2 (CD version).

P.S. I checked your latest YOU releases 5 minutes ago and I you had lauched sometimes in the last 3 days an updated version of Apache 2.0.54 including updates for worker & prefork modules. Not for this problem unfortunably :-)

Comment 14 Francois Chenier 2006-02-12 02:10:06 UTC
I performed some tests with Apache2.2/PHP5.1.2, Apache2.0/PHP5.0.4 & Apache2.0/PHP4.4.0 this week and here is my observations.

First, using Apache2.2 or Apache 2.0 with PHP 5.x gives approximatively the same results for all tests. I used the program above for test purposes.

With SuSE php-odbc related package ...
  Apache2.2/PHP5.1.2 with MySQL ODBC driver - Works with issues (note 1).
  Apache2.2/PHP5.1.2 with UnixODBC SQI driver - Not working at all.
  Apache2.0/PHP5.0.4 same results as Apache2.2/PHP5.1.2
  Apache2.0/PHP4.4.0 with MySQL ODBC driver - Not working at all.
  Apache2.0/PHP4.4.0 with UnixODBC SQI driver - Not working at all.
  Apache2.x/PHP4/5 with php-mysql (not ODBC) package - Work fine and flawlessly.

With Fedora Core 4 php-odbc related package ...
  Apache2.2/PHP5.1.2 with MySQL ODBC driver - Works with issues (note 1).
  Apache2.2/PHP5.1.2 with UnixODBC SQI driver - Works with issues (note 1).
  Apache2.0/PHP5.0.4 same results as Apache2.2/PHP5.1.2
  Apache2.0/PHP4.4.0 with MySQL ODBC driver - Works with issues (note 1).
  Apache2.0/PHP4.4.0 with UnixODBC SQI driver - Works with issues (note 1).

Note 1 : Works fine for a while & get message "Allowed memory size of 8388608 bytes exhausted" after 8-10 retries of reloading the page.

Note 2 : Not working at all means I always have the message "Allowed memory size of 8388608 bytes exhausted" in my Apache2 error file.

Comment 15 Petr Ostadal 2006-03-22 10:28:06 UTC
Francois, I added some patches from upstream to fix bugs in PHP5.1.2, could you please test it again? (you can find it again on ftp://ftp.suse.com/pub/projects/apache/php5)
Comment 16 Petr Ostadal 2006-04-15 20:36:21 UTC
no response, I close it