From: christopher dot jones at oracle dot com Operating system: n/a PHP version: 5.3CVS-2008-01-31 (snap) PHP Bug Type: OCI8 related Bug description: Incorrect use of OCI-Lob->close() causes crash
Description: ------------ Incorrect use of OCI-Lob->close() can cause a crash. The crash is ultimately due to Oracle bug 6786812 and is related to thread handling. It reproduces with PHP 5.3 (after DRCP support was added). It is likely to reproduce in threaded builds of PHP 5.x on Windows. There is a code workaround below, but because this might add to the roundtrip count in the general case, I'd like to investigate other solutions. --- oci8_lob.c 24 Jan 2008 14:09:36 -0000 1.7.2.6.2.14.2.3 +++ oci8_lob.c 31 Jan 2008 21:27:10 -0000 @@ -570,13 +570,17 @@ int php_oci_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) { php_oci_connection *connection = descriptor->connection; - - PHP_OCI_CALL_RETURN(connection->errcode, OCILobClose, (connection->svc, connection->err, descriptor->descriptor)); + boolean flag = 0; - if (connection->errcode != OCI_SUCCESS) { - php_oci_error(connection->err, connection->errcode TSRMLS_CC); - PHP_OCI_HANDLE_ERROR(connection, connection->errcode); - return 1; + PHP_OCI_CALL_RETURN(connection->errcode, OCILobIsOpen, (connection->svc, connection->err, descriptor->descriptor, &flag)); + if (connection->errcode == OCI_SUCCESS && flag) { + PHP_OCI_CALL_RETURN(connection->errcode, OCILobClose, (connection->svc, connection->err, descriptor->descriptor)); + + if (connection->errcode != OCI_SUCCESS) { + php_oci_error(connection->err, connection->errcode TSRMLS_CC); + PHP_OCI_HANDLE_ERROR(connection, connection->errcode); + return 1; + } } Reproduce code: --------------- <?php $c = oci_connect('hr', 'hrpwd', '//ca-tools1/XE'); $stmtarray = array( "create or replace procedure ctest (p in out clob) as begin p := 'A'; end;" ); foreach ($stmtarray as $stmt) { $s = oci_parse($c, $stmt); @oci_execute($s); } $stmt = oci_parse($c,'begin ctest(:c_data); end;'); $textLob = oci_new_descriptor($c, OCI_D_LOB); oci_bind_by_name($stmt, ":c_data", $textLob, -1, OCI_B_CLOB); oci_execute($stmt, OCI_DEFAULT); $r = $textLob->load(); echo $r; // Incorrectly closing the lob causes a crash. OCI-LOB->close() is // documented for use only with OCI-Lob->writeTemporary() $textLob->close(); print "ok\n"; ?> -- Edit bug report at http://bugs.php.net/?id=44008&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=44008&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44008&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44008&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44008&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44008&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44008&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44008&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44008&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44008&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44008&r=support Expected behavior: http://bugs.php.net/fix.php?id=44008&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44008&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44008&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44008&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=44008&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=44008&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44008&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44008&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44008&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44008&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44008&r=mysqlcfg