|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2004-12-09 16:01 UTC] damien dot harper at keops dot net
 Description:
------------
Apache crashes (segmentation fault) as soon as it encounters 
 the ocilogon instruction.
Everything works like a charm from command line!
sqlplus connects and queries without any errors.
For information :
Apache 2.0.52 compiled and installed with :
./configure -?enable-shared=max
make
make install
PHP 4.3.10RC2 (same problem with PHP 4.3.9) compiled and installed with :
./configure --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --prefix=/usr --with-config-file-path=/etc --disable-debug --enable-pic --enable-inline-optimization --with-curl --with-dom=/usr --with-exec-dir=/usr/bin --with-gettext --with-ncurses --with-regex=system --with-xml --with-expat-dir=/usr --with-zlib --enable-bcmath --enable-exif --enable-ftp --enable-magic-quotes --enable-safe-mode --enable-sockets --enable-track-vars --enable-trans-sid --with-pear=/usr/share/pear --with-mysql=shared --with-oci8=shared --enable-bcmath --with-apxs2=/usr/local/apache2/bin/apxs
make
make install
Oracle Client 9.2.0.1 (same problem with 9.2.0.2 and 9.2.0.3)
Oracle database is 8.1.6 (same problem with our test database which is Oracle 9i)
Reproduce code:
---------------
$username = "*****";
$passwd = "*****";
$host = "10.211.162.35";
$port = "1521";
$service = "SIRENET";
$db="(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port)))(CONNECT_DATA=(SERVICE_NAME=$service)))";
$conn = OCILogon($username,$passwd,$db);
if (!$conn) {
   echo "Connection failed";
   echo "Error Message: [" . OCIError($conn) . "]";
   exit;
} else {
        echo "Connected!"."\n";
        $parse=OCIParse($conn,"select che_nocheval from cheval where rownum < 10"); 
 //     OCIDefineByName($parse,"che_nocheval",$che_nocheval);
        OCIExecute($parse,OCI_DEFAULT);
        echo "\nRecuperation de donnees\n";
        $nrows = ocifetchstatement($parse, $rs, 0, 100,OCI_NUM);
                                $resultTab = "";
                                $numCol = 0;
                                for ( $iRow = 0; $iRow < $nrows; $iRow++ ) {
                                        reset($rs);
                                        while ( $column = each($rs) ) {
                                                 $data = $column['value'];
                                                 $resultTab[$iRow][$numCol] = $data[$iRow];
                                                echo $iRow.'|'.$numCol.'|'.$resultTab[$iRow][$numCol];
                                                $numCol++;
                                        }
                                        $numCol = 0;
                                }
        OCIFreeStatement($parse);
        OCILogoff($conn);
}
Actual result:
--------------
Apache segfaults
Starting program: /usr/local/apache2/bin/httpd -X
[New Thread 8192 (LWP 2417)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 8192 (LWP 2417)]
0x4078fd5d in lxhcsn () from /home/oracle/OraHome1/lib/libclntsh.so.9.0
(gdb) bt
#0  0x4078fd5d in lxhcsn () from /home/oracle/OraHome1/lib/libclntsh.so.9.0
#1  0x40274837 in kpcsnevget () from /home/oracle/OraHome1/lib/libclntsh.so.9.0
#2  0x401ecae2 in OCINlsEnvironmentVariableGet () from /home/oracle/OraHome1/lib/libclntsh.so.9.0
#3  0x4113eb53 in _oci_open_session (server=0x8224cb8, username=0x821735c "sirenet", password=0x82174ec "sirenet", 
    persistent=0, exclusive=0, charset=0x4114595d "") at /root/kic_temp/php-4.3.9/ext/oci8/oci8.c:2183
#4  0x4113f9e6 in oci_do_connect (ht=3, return_value=0x82176d4, this_ptr=0x0, return_value_used=1, persistent=0, 
    exclusive=0) at /root/kic_temp/php-4.3.9/ext/oci8/oci8.c:2715
#5  0x41142d83 in zif_ocilogon (ht=3, return_value=0x82176d4, this_ptr=0x0, return_value_used=1)
    at /root/kic_temp/php-4.3.9/ext/oci8/oci8.c:4340
#6  0x40c8e866 in execute (op_array=0x8212914) at /root/kic_temp/php-4.3.9/Zend/zend_execute.c:1640
#7  0x40c81ea3 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /root/kic_temp/php-4.3.9/Zend/zend.c:891
#8  0x40c5c563 in php_execute_script (primary_file=0xbffff6d0) at /root/kic_temp/php-4.3.9/main/main.c:1735
#9  0x40c9315a in php_handler (r=0x820a698) at /root/kic_temp/php-4.3.9/sapi/apache2handler/sapi_apache2.c:540
#10 0x0807c902 in ap_run_handler (r=0x820a698) at config.c:152
#11 0x0807ce1a in ap_invoke_handler (r=0x820a698) at config.c:363
#12 0x0806c5d3 in ap_process_request (r=0x820a698) at http_request.c:246
#13 0x080686ad in ap_process_http_connection (c=0x82064b8) at http_core.c:250
#14 0x08085ba6 in ap_run_process_connection (c=0x82064b8) at connection.c:42
#15 0x0807b47b in child_main (child_num_arg=0) at prefork.c:609
#16 0x0807b626 in make_child (s=0x80ba0c8, slot=0) at prefork.c:649
#17 0x0807b67f in startup_children (number_to_start=8) at prefork.c:721
#18 0x0807bd8d in ap_mpm_run (_pconf=0x807ae44, plog=0x80eda70, s=0x80ba0c8) at prefork.c:940
#19 0x08080d42 in main (argc=2, argv=0xbffffa24) at main.c:617
#20 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6
(gdb) 
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 11:00:01 2025 UTC | 
This is pure guess, but in file ext/oci8/oci8.c try changing the number 2 on line 2180 to 0 (zero) and recompile PHP. Patch here: Index: oci8.c =================================================================== RCS file: /repository/php-src/ext/oci8/oci8.c,v retrieving revision 1.183.2.16 diff -u -r1.183.2.16 oci8.c --- oci8.c 3 Nov 2004 13:35:56 -0000 1.183.2.16 +++ oci8.c 13 Dec 2004 23:02:12 -0000 @@ -2177,7 +2177,7 @@ /* Safe, charsetid is initialized to 0 */ CALL_OCI(OCINlsEnvironmentVariableGet(&charsetid, - 2, + 0, OCI_NLS_CHARSET_ID, 0, &rsize));PHP 4.3.10RC2 Oracle 9 database Oracle 9.2.0.1 client Everything works fine using command line : php myscript.php gives me expected results export ORACLE_SID="ORACLE9" export ORACLE_HOME="/home/oracle/OraHome1" export LD_LIBRARY_PATH="/home/oracle/OraHome1/lib" export TNS_ADMIN="/home/oracle/OraHome1/network/admin/tnsnames.ora" export NLS_LANG="English_America.WE8ISO8859P1" here is the script : <?php include "queries/fonctionsDb.php"; $username = "sirenet"; $passwd = "sirenet"; $host = "172.16.0.7"; $port = "1521"; $service = "ORACLE9"; //$db="(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port)))(CONNECT_DATA=(SERVICE_NAME=$service)))"; $db="SIRENET"; $conn = connection(); if (!$conn) { echo "Connection failed"; echo "Error Message: [" . OCIError($conn) . "]"; exit; } else { echo "Connected!"."\n"; $parse=OCIParse($conn,"select nom from chevaux"); OCIExecute($parse,OCI_DEFAULT); echo "\nRecuperation de donnees\n"; $nrows = ocifetchstatement($parse, $rs, 0, 100,OCI_NUM); $resultTab = ""; $numCol = 0; for ( $iRow = 0; $iRow < $nrows; $iRow++ ) { reset($rs); while ( $column = each($rs) ) { $data = $column['value']; $resultTab[$iRow][$numCol] = $data[$iRow]; echo $iRow.'|'.$numCol.'|'.$resultTab[$iRow][$numCol]; $numCol++; } $numCol = 0; } OCIFreeStatement($parse); deconnection($conn); } ?>Wooops, I forgot the interesting part of the included file fonctionsDb.php : <?php ... function connection(){ global $errorCode,$test; $host = "172.16.0.7"; $port = "1521"; $service = "ORACLE9"; $user = "sirenet"; $pwd = "sirenet"; $db="(DESCRIPTION=(ADDRESS_LIST= (ADDRESS=(PROTOCOL=TCP) (HOST=$host)(PORT=$port) ) ) (CONNECT_DATA=(SERVICE_NAME=$service)) )"; if ($test==1){ $conn = ocilogon($user,$pwd,$db); } else { $conn = @ocilogon($user,$pwd,$db); } if ($conn==""){ $errorCode = 2; } return $conn; } function deconnection($conn){ ocilogoff($conn); } ... ?>