php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56576 SegFault if PDO_OCI8 DSN is incorrect and PDO_ATTR_PERSISTENT == true
Submitted: 2005-10-03 09:05 UTC Modified: 2005-10-26 23:51 UTC
From: max2k1 at yandex dot ru Assigned: wez (profile)
Status: Closed Package: PDO (PECL)
PHP Version: 4.2.2 OS: CentOS release 4.1
Private report: No CVE-ID: None
 [2005-10-03 09:05 UTC] max2k1 at yandex dot ru
Description:
------------
I'm trying to connect to my Oracle 10g DB, running on the same machine and mistyped dbname ("oci:dbname=orama" instead of "oci:dbname=oramax").
After execution i've got Segmentation fault. After doing some little research, i've found that segfault appears only if PDO_ATTR_PERSISTENT is set to true.

GDB output was:
Starting program: /usr/bin/php ./bug.php
[Thread debugging using libthread_db enabled]
[New Thread 182894211648 (LWP 27798)]
SQLSTATE[42S02]: pdo_oci_handle_factory: ORA-12154: TNS:could not resolve the connect identifier specified
 (/home/users/php/src/compile/pdo/pecl/pdo_oci/oci_driver.c:463)
Failure :(

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 182894211648 (LWP 27798)]
0x0000002a9a702f26 in pdo_dbh_free_storage (dbh=0xa556f0) at /home/users/php/src/compile/pdo/pecl/PDO-1.0RC1/pdo_dbh.c:1161
1161            } else if (dbh->methods->persistent_shutdown) {

My info:
$ pear list
Package              Version State
PDO                  1.0RC1  beta
PDO_OCI              1.0RC1  beta
oci8                 1.1     beta

$ php -v
PHP 5.0.4 (cli) (built: Sep 20 2005 20:41:23)

PHP Configure Command =>  './configure' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-pear=/usr/share/pear' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/etc/httpd/conf/magic' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--enable-force-cgi-redirect' '--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-ncurses=shared' '--with-gd=shared' '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--with-ldap=shared' '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/bin/mysql_config' '--with-oci8-instant-client=shared' '--enable-dom=shared' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-xsl=shared,/usr' '--enable-fastcgi'





Reproduce code:
---------------
<?php
$m_DSN = "oci:dbname=orama";
$m_user = "scott";
$m_password = "tiger";
try {
  $m_dbh = new PDO($m_DSN, $m_user, $m_password,
    array(PDO_ATTR_PERSISTENT => true));
  echo "Success!\n";
} catch (PDOException $e) {
  echo $e->getMessage();
  die("\nFailure :(\n");
}
?>

Expected result:
----------------
SQLSTATE[42S02]: pdo_oci_handle_factory: ORA-12154: TNS:could not resolve the connect identifier specified
 (/home/users/php/src/compile/pdo/pecl/pdo_oci/oci_driver.c:463)
Failure :(

Actual result:
--------------
SQLSTATE[42S02]: pdo_oci_handle_factory: ORA-12154: TNS:could not resolve the connect identifier specified
 (/home/users/php/src/compile/pdo/pecl/pdo_oci/oci_driver.c:463)
Failure :(
Segmentation fault


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-03 09:14 UTC] max2k1 at yandex dot ru
diff that solved the problem for me:
--- ./pdo_dbh.c 2005-09-10 23:48:43.000000000 +0600
+++ ../PDO-1.0RC1new/pdo_dbh.c  2005-10-03 19:11:04.238751673 +0600
@@ -1158,7 +1158,7 @@

        if (!dbh->is_persistent) {
                dbh_free(dbh TSRMLS_CC);
-       } else if (dbh->methods->persistent_shutdown) {
+       } else if ((dbh->methods) && (dbh->methods->persistent_shutdown)) {
                dbh->methods->persistent_shutdown(dbh TSRMLS_CC);
        }
 }
 [2005-10-26 23:51 UTC] wez@php.net
Fixed in CVS for PHP 5.1.
 [2010-03-01 20:32 UTC] khaja dot azharuddin at gmail dot com
We are getting error while we open the web page.Any one can tell me what is exact mean of it.  


SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12520: TNS:listener could not find available handler for requested type of server
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC