PHP5 + oci8 consistently segfaults on script exit

View: New views
4 Messages — Rating Filter:   Alert me  

PHP5 + oci8 consistently segfaults on script exit

by Gordon Stratton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey,

I'm running FreeBSD 6.2-RELEASE-p1 and PHP 5.2.2 built with the oci8
extension which is built against the oracle8-client port version
0.1.1_1.

Connecting to and working with an Oracle database works well so far, but
PHP segfaults whenever any script that uses the oci8 extension is run
and exits (regardless of success or failure).  The segfault _only_
occurs when PHP is tearing everything down after the script runs.
Therefore scripts run successfully, but my kernel logs look like this:

Jul 25 16:59:17 kernel: pid 89667 (php), uid 1003: exited on signal 11
Jul 25 17:00:11 kernel: pid 89725 (php), uid 1003: exited on signal 11
Jul 25 17:01:38 kernel: pid 89729 (php), uid 1003: exited on signal 11
Jul 25 17:02:58 kernel: pid 89732 (php), uid 1003: exited on signal 11
...

Using gdb I've tracked the segfault down to a call to dlclose (via the
macro DL_UNLOAD in Zend/zend_API.c on line 1916).  The module being
unloaded when the segfault occurs is the oci extension.

So far, I've tried:

- Various combinations of environment variables per the PHP
  documentation

- Messing around remapping symbols as outlined in README.PORT that
  ships with oracle8-client and rebuilding oci8 each time

- Not loading other PHP extensions

- Loading other PHP extensions in a different order

- Googling until I've memorized the 10 or so pages related to my problem

The problem has persisted across multiple versions of PHP in the last
several months, and pretty much everything I've tried results in a
working oci8 with the segfault after the script finishes.  Today we
experienced some very odd behavior with a large Oracle query and httpd
exiting on signal 4 and while they may not be related, I'd like to see
if it's at all possible to resolve this issue (in the spirit of ruling
things out).  Anything is welcome, I've heard of at least one other
person with my problem (and nearly identical setup) so I don't think I'm
the only one out there.

Thanks for your time,

Gordon
_______________________________________________
freebsd-database@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-database
To unsubscribe, send any mail to "freebsd-database-unsubscribe@..."

Parent Message unknown Re: PHP5 + oci8 consistently segfaults on script exit

by Simun Mikecin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>I'm running FreeBSD 6.2-RELEASE-p1 and PHP 5.2.2 built with the oci8
>extension which is built against the oracle8-client port version
>0.1.1_1.

>Connecting to and working with an Oracle database works well so far, but
>PHP segfaults whenever any script that uses the oci8 extension is run
>and exits (regardless of success or failure).  The segfault _only_
>occurs when PHP is tearing everything down after the script runs.
>Therefore scripts run successfully, but my kernel logs look like this:

>Jul 25 16:59:17 kernel: pid 89667 (php), uid 1003: exited on signal 11
>Jul 25 17:00:11 kernel: pid 89725 (php), uid 1003: exited on signal 11
>Jul 25 17:01:38 kernel: pid 89729 (php), uid 1003: exited on signal 11
>Jul 25 17:02:58 kernel: pid 89732 (php), uid 1003: exited on signal 11

Could you please try these and send feedback:

1) Try the same using PDO_OCI instead of oci8 extension
2) Try with this combination: apache 2.0 (port compiled with WITH_THREADS) + php + oci8 extension
3) Try with this combination: apache 2.0 (port compiled with WITH_THREADS) + php + PDO_OCI

2) and 3) should be triggered by HTTP request.



       
____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/
_______________________________________________
freebsd-database@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-database
To unsubscribe, send any mail to "freebsd-database-unsubscribe@..."

Re: PHP5 + oci8 consistently segfaults on script exit

by Gordon Stratton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 7/28/07, Simun Mikecin <numisemis@...> wrote:
> Could you please try these and send feedback:
>
> 1) Try the same using PDO_OCI instead of oci8 extension
> 2) Try with this combination: apache 2.0 (port compiled with WITH_THREADS) + php + oci8 extension
> 3) Try with this combination: apache 2.0 (port compiled with WITH_THREADS) + php + PDO_OCI
>
> 2) and 3) should be triggered by HTTP request.

Hey Simun,

1) Segfaults on exit, same as oci8.

2) Does not segfault.

3) Does not segfault.

In my situation, everything works like a charm up until the module is
unloaded via dlclose(3).  My guess is that since mod_php doesn't
unload/reload PHP modules across requests that this is the reason it is
not segfaulting with httpd, but segfaulting with CLI PHP.

Thanks,

Gordon
_______________________________________________
freebsd-database@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-database
To unsubscribe, send any mail to "freebsd-database-unsubscribe@..."

Re: PHP5 + oci8 consistently segfaults on script exit

by Gordon Stratton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've implemented a solution that works around the problem. I'm fairly
sure that the Oracle shared library is doing something incorrect such as
registering functions via atexit(3). When the module is unloaded and PHP
exits, the called functions have since been unmapped so calling them
results in a segfault. Does this sound plausible? In any case, my
workaround is to comment out the call to the macro DL_UNLOAD in
Zend/zend_API.c (the macro expands to the call to dlclose(3) on FreeBSD
and other platforms). Doing it at that point works out because PHP
always exits after dlclose(3)ing all of its extensions (hence the
segfault), but clearly it is not an elegant or clean solution.

I have prepared a patch which I am using in my local ports tree that
comments out DL_UNLOAD as I mentioned earlier, and everything is working
just fine (CLI and mod_php) on FreeBSD 6.2 with PHP 5.2.3 and
oracle8-client-0.1.1_1.

If anyone is interested in this patch, contact me off-list.

Gordon
_______________________________________________
freebsd-database@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-database
To unsubscribe, send any mail to "freebsd-database-unsubscribe@..."