Red Hat Bugzilla – Bug 483690
PHP odbc with UnixODBC causes hang or Segfault when driver changes
Last modified: 2010-03-30 04:24:43 EDT
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):
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'
If compiled with thread support it will 'hang' forever. If compiled without thread support it will cause a SEG Fault.
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)
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.
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 "?".
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.
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.
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.
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.