php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32485 PHP/OCI8 segfaults after the script ends
Submitted: 2005-03-29 15:48 UTC Modified: 2005-04-01 15:16 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: phpbug at pech dot cz Assigned:
Status: Not a bug Package: OCI8 related
PHP Version: 5.0.3 OS: Linux 2.4.22
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phpbug at pech dot cz
New email:
PHP Version: OS:

 

 [2005-03-29 15:48 UTC] phpbug at pech dot cz
Description:
------------
PHP with OCI8 segfaults just _after_ the script ends, when executed from command line by php -q <anyscript.php. 

Everything is processed fine, but _after_ the script ends (past the processing of the last line), segmentation fault occurs and the core is dumped by php.


Reproduce code:
---------------
<?php
  $conn = oci_connect ($user, $password, $db);
?>


Expected result:
----------------
Print nothing. In general, expected result means that it will end without segmentation fault.

Actual result:
--------------
Backtrace (seems really strange to me):
#0  0x04ac8a8c in ?? ()
#1  0x00af3a90 in exit () from /lib/tls/libc.so.6
#2  0x00adeade in __libc_start_main () from /lib/tls/libc.so.6
#3  0x080738e1 in _start ()

When I accidentally forgotten to set evnironment variable ORA_NLS33, it prints:

PHP Warning:  oci_connect() [<a href='function.oci-connect'>function.oci-connect</a>]: _oci_open_server: Error while trying to retrieve text for error ORA-12154
 in - on line 2
-(2) : Warning - oci_connect() [<a href='function.oci-connect'>function.oci-connect</a>]: _oci_open_server: Error while trying to retrieve text for error ORA-12154

/usr/src/redhat/BUILD/php-5.0.3/ext/oci8/oci8.c(3065) :  Freeing 0x09A1E4BC (20 bytes), script=-
=== Total 1 memory leaks detected ===

"Error while trying to retrieve text for error ORA-12154" is OK, becuase all environment variables are not set and exported, but the error ORA-12154 and the memory leak are not.

Please feel free to contact me for any further details if needed.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-29 17:39 UTC] sniper@php.net
You don't have the Oracle environment variables set correctly. 
 [2005-03-29 18:21 UTC] phpbug at pech dot cz
Sorry, but I don't think so. Of course I haven't set them up  and then a memory leak was reported, but normally I have all the variables (like ORACLE_HOME, ORACLE_BASE, ORA_NLS33 and NLS_LANG) set up fine. And everything works in PHP4, but not in PHP5.

The biggest problem is the segfault after processing the script, not the memory leak (which I've reported just for help you to find out what's wrong). But there may be no connection between then memory leak (when env vars unset) and the segfault.
 [2005-03-29 18:38 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip

Can't reproduce it. 
Check twice and then recheck that you have set all the required env vars like ORACLE_HOME, TNS_ADMIN etc. and that they are available for Apache user.
 [2005-03-29 20:40 UTC] phpbug at pech dot cz
Hi Tony!

I'm not running it from apache, but from the command line (as mentioned above). The server is running for years (from Fedora Core 1) without any significant changes, except of kernel updates and so. Segfaults appeared first with upgrade of PHP to 5.0.3 (previous was 4.3.10).

Environment variables are set up fine (as mentioned above). TNS_ADMIN is not set, but this is strictly optional, because the client always looks for tnsnames.ora file to $ORACLE_HOME/network/admin. Connection is established on oci_connect() call, I can also do any database processing and then call oci_close(), but it segfaults _after_ the script ends (which looks like some error in eg. free() call). Maybe the problem is in the combination of PHP5 vs. Oracle 8.1.7.4 client or a part of it. I don't have an instant client, but regular 8.1.7.4 server on the same machine.

I'll try the latest snapshot as soon as possible and I'll let you know.
 [2005-04-01 11:43 UTC] phpbug at pech dot cz
Hi Tony,

  latest CVS version did not fixed it, so I went through the the runtime and compile time configuration and I've found that the configuration, which worked fine with Fedora Core 1-2/Oracle 8.1.7.4/PHP4 was:

export ORACLE_BASE=your_location
export ORACLE_HOME=$ORACLE_BASE
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export ORA_LOG=your_log_location
export NLS_LANG=your_encoding
export NLS_SORT="your_sort_style"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:${LD_LIBRARY_PATH}
export LD_ASSUME_KERNEL=2.2.5
#export LD_PRELOAD=$ORACLE_HOME/lib/libclntsh.so

When LD_PRELOAD was set (properly) with PHP4, apache never started up. But it works fine with PHP5 and we, fortunatelly, have no more strange core dumps.

I apologize, you've said that. So, please, mark this as bogus, but maybe leave a note in the documentation. I assume that it impacts only some architectures.
 [2005-04-01 15:16 UTC] sniper@php.net
IIRC, there is a note about setting the environment variables in the manual..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 09:01:29 2024 UTC