php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44560 Apache crashes with PDO_OCI and both persistent and non-persistent connections.
Submitted: 2008-03-28 14:53 UTC Modified: 2009-05-20 01:00 UTC
From: jarismar dot php at gmail dot com Assigned: mbeccati
Status: No Feedback Package: PDO related
PHP Version: 5.2.6RC3 OS: Windows XP SP2
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-03-28 14:53 UTC] jarismar dot php at gmail dot com
Description:
------------
Sometimes our DBAs restart oracle without restarting the apache server, due to this if apache has persistent connections, those connections are in invalid state.
 In this scenario trying to connect to oracle results in on of the following errors:
 ORA-00028: your session has been killed
 ORA-01012: not logged on
 ORA-03113 end-of-file on communication channel
 I'm trying to handle this errors and skipping creating the persistent connection and then creating a new non-persistent connection (see the php snippet). I was in hope that doing this could force apache to free the invalid persistent connection, but instead apache crashes (it seems a problem freeing the statements).

Reproduce code:
---------------
try {
  $oPDO = new PDO($sDSN, $sUserName, $sPassword, array(PDO::ATTR_PERSISTENT => true));
  print "Persistent connection created\n";
  $oPDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (Exception $oE) {
  echo "Error : ".$oE->getMessage()."\n";
  $oPDO = new PDO($sDSN, $sUserName, $sPassword, array(PDO::ATTR_PERSISTENT => false));
  print "Non persistent connection created\n";
}

try {
  $oStatement = $oPDO->prepare('Select 1+1 as test from dual');
  var_dump($oStatement->execute());
  var_dump($oStatement->fetchAll());
} catch (Exception $oE) {
  echo "Error : ".$oE->getMessage()."\n";
} 

$oPDO = null;

Expected result:
----------------
  I expect either the system get ride of invalid persistent connections or when one create a non-peristent connection it replaces the persistent one if there is any.


Actual result:
--------------
  Unhandled exception at 0x0087ac76 (php5ts.dll) in Apache.exe: 0xC0000005: Access violation reading location 0x002b5ffc.
>	php5ts.dll!_zend_mm_free_int(_zend_mm_heap * heap=0x01ded100, void * p=0x0005000c)  Line 1960	C
 	php5ts.dll!_efree(void * ptr=0x00265ff8)  Line 2293 + 0xb bytes	C
 	php_pdo_oci.dll!oci_stmt_dtor(_pdo_stmt_t * stmt=0x00000000, void * * * tsrm_ls=0x01debeb0)  Line 90 + 0x3 bytes	C
 	php_pdo.dll!free_statement(_pdo_stmt_t * stmt=0x02b9ad48, void * * * tsrm_ls=0x01debeb0)  Line 2355 + 0x8 bytes	C
 	php_pdo.dll!php_pdo_stmt_delref(_pdo_stmt_t * stmt=0x02b9ad48, void * * * tsrm_ls=0x01debeb0)  Line 2397 + 0xb bytes	C
 	php_pdo.dll!pdo_dbstmt_free_storage(_pdo_stmt_t * stmt=0x02b9ad48, void * * * tsrm_ls=0x01debeb0)  Line 2402 + 0xf bytes	C
 	php5ts.dll!zend_objects_store_del_ref_by_handle(unsigned int handle=2, void * * * tsrm_ls=0x01debeb0)  Line 206 + 0x11 bytes	C
 	php5ts.dll!zend_objects_store_del_ref(_zval_struct * zobject=0x02b9ab00, void * * * tsrm_ls=0x01debeb0)  Line 169	C
 	php5ts.dll!_zval_dtor_func(_zval_struct * zvalue=0x02b9ab00)  Line 60	C
 	php5ts.dll!_zval_ptr_dtor(_zval_struct * * zval_ptr=0x02b9aefc)  Line 414 + 0xc bytes	C
 	php5ts.dll!zend_hash_apply_deleter(_hashtable * ht=0x01e22460, bucket * p=0x02b9aef0)  Line 611 + 0x6 bytes	C
 	php5ts.dll!zend_hash_reverse_apply(_hashtable * ht=0x01e22460, int (void *, void * * *)* apply_func=0x00907bb0, void * * * tsrm_ls=0x01debeb0)  Line 760 + 0xb bytes	C
 	php5ts.dll!shutdown_destructors(void * * * tsrm_ls=0x01debeb0)  Line 212	C
 	php5ts.dll!zend_call_destructors(void * * * tsrm_ls=0x01debeb0)  Line 845 + 0x6 bytes	C
 	php5ts.dll!php_request_shutdown(void * dummy=0x00000000)  Line 1445 + 0x6 bytes	C
 	php5apache2.dll!php_apache_request_dtor(request_rec * r=0x01bc6de0, void * * * tsrm_ls=0x01debeb0)  Line 468 + 0x8 bytes	C
 	php5apache2.dll!php_handler(request_rec * r=0x01bc6de0)  Line 641 + 0x7 bytes	C
 	libhttpd.dll!6ff01575() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for libhttpd.dll]	
 	libhttpd.dll!6ff019fd() 	
 	libhttpd.dll!6ff0e15c() 	
 	libhttpd.dll!6ff09966() 	
 	libhttpd.dll!6ff04275() 	
 	libhttpd.dll!6ff044f2() 	
 	libhttpd.dll!6ff1c3b8() 	
 	msvcr71.dll!7c36b381() 	
 	ntdll.dll!7c91849f() 	
 	msvcr71.dll!7c3638e2() 	
 	kernel32.dll!7c80b683() 	
 	ntdll.dll!7c91849f() 	


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-28 15:57 UTC] jarismar_silva at adplabs dot com dot br
You can more reproduce this error by killing the persistent connection.
First you need to discovering the SID and Serial# from the persistent 
connection in order to kill it:

This SQL retrieve SID and SERIAL# :
select * from  (
select
  nvl(ses.USERNAME,'ORACLE PROC') username,
  PROGRAM,
  MACHINE,
  ses.status status,
	PROCESS pid,
	ses.SID SID,
	SERIAL#
from	v$session ses,
	v$sess_io sio
where 	ses.SID = sio.SID
order 	by PHYSICAL_READS, ses.USERNAME
) where username = 'RPTDEV7'
order by machine, pid, sid

Then kill the session with
ALTER SYSTEM KILL SESSION '<SID>,<SERIAL#>';
 [2009-04-25 14:57 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-05-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-05-04 17:02 UTC] jarismar dot php at gmail dot com
Reproduced with PHP Version 5.2.10-dev (Build Date Apr 26 2009 23:39:22)

Someone else have been able to reproduced this bug ? Here is some instructions on how to do it :
1. run the snipped once
2. kill the persistent connection on oracle (see sqls on the second note)
3. run the snipped again

So infortunatelly the bug is not yet fixed on 5.2.10-dev.
 [2009-05-12 22:04 UTC] mbeccati@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

This bug should be fixed after applying the fix for #48070
 [2009-05-20 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 10:03:03 2014 UTC