From:             martin dot pala at oskar dot cz
Operating system: Solaris 9
PHP version:      5.0.3
PHP Bug Type:     Reproducible crash
Bug description:  [PATCH] OCI extension -- crash in _oci_close_session

Description:
------------
We are running PHP-5.0.3 and Apache-1.3.31 on Solaris 9. There is
application written in PHP which is able to crash PHP anytime specific
script which is using OCI extension is called. The backtrace is:

---8<---
core 'core' of 18430:   /usr/apache/bin/httpd
 fd8c038c _oci_close_session (636978, 15, ffbff014, fdcc2240, fdcc222c,
636978) + 9c
 fd9d7900 list_entry_destructor (5d93c8, 75c00, 10, 2654f0, 0, 252a0) +
74
 fd9d657c zend_hash_apply_deleter (fdcc65d0, 6bae80, 10, 5ad1cba6, 2654c0,
238710) + 194
 fd9d6604 zend_hash_graceful_reverse_destroy (fdcc65d0, fd9c0540, 0, 0, 0,
0) + 14
 fd9c14ec shutdown_executor (0, fd9ce650, 0, 0, 0, 0) + 2b8
 fd9ce6a0 zend_deactivate (fdcc6c34, fd990e30, 0, ffbff578, 0, 0) + bc
 fd990ed4 php_request_shutdown (0, fda0e308, 0, ffbff578, 0, 0) + 258
 fda0e39c apache_php_module_main (ffffffff, 0, 0, ffbff658, 0, 0) + 158
 fda0ee7c send_php (ffffffff, 0, 0, 0, 0, 0) + 334
 fda0f0f8 send_parsed_php (258428, fdbb1aa7, ffffffff, 0, 70, 70) + 18
 0001c090 ap_invoke_handler (258428, 25, 1, 6fc00, 25b438, 6) + f8
 0002fd6c ???????? (258428, fe2f0148, 1, ffbff8e4, 4, 1)
 0002fdbc ap_process_request (258428, 4, 258428, ffbff964, ffbff954, 2) +
28
 00027be8 ???????? (77c00, 77c00, 77c00, 10, 6fc00, 26000)
 00027df8 ???????? (7aa28, 2, 41e27c3a, 0, ffbffa40, 0)
 00027eb4 ???????? (4, 0, 41e27c39, 0, 1, 76d68)
 00028714 ???????? (77c00, 77c00, 77c00, 8, 0, 6fc00)
 00028dd8 main     (1, ffbffbbc, ffbffbc4, 6fc00, 0, 0) + 34c
 00017a70 _start   (0, 0, 0, 0, 0, 0) + 108
---8<---

I have tried latest PHP snapshot too - with the same result.

I tried then run Apache in single-process mode (using -X option). This
time it was stable.

Thereafter i found in the code of OCI extension (ext/oci8/oci8.c) the
dependency of OCI library initialization flag OCI_THREADED on PHP ZTS
option -> ZTS is not enabled (nor recommended) by default, thus PHP omits
this flag during initialization.

I tried then to change the OCI extension code to use this flag by default
using the patch bellow - the problem was solved, apache in multi-process
mode didn't failed anymore on the PHP script.

Patch:

---8<---
diff -Naur php-5.0.3/ext/oci8/oci8.c php-5.0.3-mp/ext/oci8/oci8.c
--- php-5.0.3/ext/oci8/oci8.c   2004-11-22 22:46:49.000000000 +0100
+++ php-5.0.3-mp/ext/oci8/oci8.c        2005-01-11 14:20:56.802128000 +0100
@@ -622,11 +622,7 @@
 
 #endif
 
-#ifdef ZTS
 #define PHP_OCI_INIT_MODE PHP_OCI_INIT_MODE_TMP | OCI_THREADED
-#else
-#define PHP_OCI_INIT_MODE PHP_OCI_INIT_MODE_TMP
-#endif
 
        mutex_alloc(mx_lock);
---8<---

It seems that to allow to run PHP OCI extension in apache multi-process
mode it is required to initialize the OCI library with OCI_THREADED flag,
otherwise PHP may cause apache to crash.

There are several other unresolved bugreports in bugs.php.net database
related to this combination (solaris + apache + php-4.x/php-5.x) and crash
in _oci_close_session().

The default initialization with OCI_THREADED should not hurt any
functionality and it seems it solves the problem.


-- 
Edit bug report at http://bugs.php.net/?id=31533&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31533&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31533&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31533&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31533&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31533&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31533&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31533&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31533&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31533&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31533&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=31533&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=31533&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31533&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31533&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31533&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31533&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31533&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31533&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31533&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31533&r=mysqlcfg

Reply via email to