Bug 483690

Summary: PHP odbc with UnixODBC causes hang or Segfault when driver changes
Product: Red Hat Enterprise Linux 5 Reporter: Deron Jensen <FeCastle>
Component: phpAssignee: Joe Orton <jorton>
Status: CLOSED ERRATA QA Contact: BaseOS QE <qe-baseos-auto>
Severity: medium Docs Contact:
Priority: low    
Version: 5.2CC: nickswanjan
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-03-30 08:24:43 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Deron Jensen 2009-02-03 00:50:51 UTC
Description of problem:
The PHP odbc extension is linked with two libraries -lodbc and -lodbcpsql.  The -lodbcpsql is the 'default' Postgres odbc library installed with unixODBC.  This driver should not be used for PG.  There is actually no need that I can see to link in a specific ODBC driver.  It appears this is specific to the RPM build for php 5.2.6 (not PHP itself).  I found patch "php-5.2.4-odbc.patch" this adds the '-lodbcpsql' to the config.m4.  Then the php odbc extension will call the old libraries unexpectedly.  I also found various e-mail threads on the internet where users were having problems with LDAP with similar symptoms.
A workaround is to modify the spec file to NOT install this patch.

Version-Release number of selected component (if applicable):
php5.2.6 (odbc)

How reproducible:
run a php script with odbc_connect after changing to the new PG driver installed with Postgres.

Steps to Reproduce:
1.  Install php (from RPM), unixODBC, and PG 8.3
2.  Change odbc.ini to use new PG driver 'psqlodbc.so' (from postgresql-odbc)
3.  Run a php script that uses 'odbc_connect'
  
Actual results:
If compiled with thread support it will 'hang' forever.  If compiled without thread support it will cause a SEG Fault.

Expected results:
Database connection

Additional info:
It appears as though part of the odbc_connect uses the driver manager libraries (libodbc) and part uses the default libraries (libodbcpsql).  It should only call libodbc libraries, and use the driver manager to decide the DSN connection settings.  You can see both libraries using "ldd" on the php odbc extension (odbc.so)
$ ldd /usr/lib/php/modules/odbc.so
        linux-gate.so.1 =>  (0x0095d000)
        libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00110000)
  (NOT NEEDED) libodbcpsql.so.2 => /usr/lib/libodbcpsql.so.2 (0x00690000)

Comment 1 Joe Orton 2009-02-26 09:26:58 UTC
Thanks for the report and analysis.

I seem to recall the -lodbcpsql patch was added, way back when, because of undefined in libodbc; I guess that was a different bug.

Comment 2 RHEL Program Management 2009-03-26 17:07:17 UTC
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release. If you would like
this request to be reviewed for the next minor release, ask your
support representative to set the next rhel-x.y flag to "?".

Comment 4 Joe Orton 2009-12-16 12:42:35 UTC
I've made test packages available which should fix this issue.  These
packages are unsupported, have not been through the standard Red Hat
QA process, and are not recommended for use on production systems.

   http://people.redhat.com/~jorton/Tikanga-php/

Use of these packages may prevent you from (automatically) upgrading
to any asynchronous security errata which are issued before the
release of RHEL 5.5 due to version mismatches.

Please record any feedback on use of these test packages (positive or
negative!) on this bug report.

Comment 7 Nick 2010-03-05 21:02:13 UTC
This bug also applies to php 4.3.9 in RHEL4.  The patch "php-4.3.1-odbc.patch" in that build also adds '-lodbcpsql', and if you try to use the postgres driver, you get the same results described in this bug.

Opened bug 570922 to cover php 4.3.9 in RHEL4.

Comment 9 errata-xmlrpc 2010-03-30 08:24:43 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2010-0241.html