cross compiled apache + libphp5.so segfaults on powerpc

Alles, was den Apache betrifft, kann hier besprochen werden.

cross compiled apache + libphp5.so segfaults on powerpc

Postby CMaurer » 14. November 2008 10:50

PHP5 loaded module seg faults: apache2.2.4 + php5.2.6 on embedded powerpc Linux version 2.6.26.2 (gcc version 4.2.2)
Apache processes seg fault with a bunch of 'child pid 5378 exit signal Segmentation fault (11)'.
How can I find out why the loaded module 'libphp5.so' causes a segfault when the standalone php binary works?

I am trying to use cross-compiled versions for powerpc of apache2.2.4 with php5.2.6 on an embedded linux board.
After cross-compiling php5.2.6, 'php -i' crashes with a 'Balloc() allocation exceeds list boundary', this seems to be a byte ordering issue, I fixed this by setting 'export ac_cv_c_bigendian_php=yes' before calling configure, see below.
I can now call the standalone php binary 'sapi/cli/php -f <file.php>' but when I use 'LoadModule php5_module modules/libphp5.so' in httpd.conf,
*any* request (.html, *.php) causes a bunch of 'child pid 5378 exit signal Segmentation fault (11)'.
I cannot manage to produce a core dump, 'ulimit unlimited' and 'CoreDumpDirectory ./coredump' in httpd.conf produces a zero-size file './coredump/core'.
This is an embedded system, so there is no gdb etc. on it.

How can I find out why the loaded module causes a segfault when the standalone php binary works?
Any help is appreciated!



httpd.conf:
ServerName <removed ip>
ServerRoot "./"
DocumentRoot "./www/"
LogLevel debug
LoadModule mime_module modules/mod_mime.so
LoadModule php5_module modules/libphp5.so
Listen <removed ip>:8080
User nobody


PHP cross-compile settings:
export PATH=/usr/local/ELDK-4.2/usr/ppc-linux/bin:/usr/local/ELDK-4.2/usr/bin:/usr/local/ELDK-4.2/bin:/usr/local/ELDK-4.2/sbin:$PATH
export CROSS_COMPILE=ppc_85xxDP-
export ac_cv_c_bigendian_php=yes
./configure --build=i386-linux --host=ppc-linux \
--with-apxs2=/home/christoph/apache-x86/bin/apxs \
--with-config-file-path=/home/christoph/apache-ppc/php \
--disable-all \
--prefix=/home/christoph/apache-ppc


PHP version:
# php -v
PHP 5.2.6 (cli) (built: Nov 14 2008 09:33:02)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies


apache error log 'logs/error_log':
[Fri Nov 14 09:26:46 2008] [debug] mod_so.c(246): loaded module mime_module
[Fri Nov 14 09:26:46 2008] [debug] mod_so.c(246): loaded module php5_module
[Fri Nov 14 09:26:47 2008] [notice] Apache/2.2.4 (Unix) PHP/5.2.6 configured -- resuming normal operations
[Fri Nov 14 09:26:47 2008] [info] Server built: Apr 2 2008 16:30:30
[Fri Nov 14 09:26:47 2008] [debug] prefork.c(991): AcceptMutex: sysvsem (default: sysvsem)
< now I request a 'http://ip:8080/test.html' >
[Fri Nov 14 09:28:25 2008] [notice] child pid 5378 exit signal Segmentation fault (11)
[Fri Nov 14 09:28:25 2008] [notice] child pid 5379 exit signal Segmentation fault (11)
[Fri Nov 14 09:28:25 2008] [notice] child pid 5380 exit signal Segmentation fault (11)
[Fri Nov 14 09:28:28 2008] [notice] child pid 5381 exit signal Segmentation fault (11)


apache version:
# httpd -V
Server version: Apache/2.2.4 (Unix)
Server built: Apr 2 2008 16:30:30
Server's Module Magic Number: 20051115:4
Server loaded: APR 1.2.8, APR-Util 1.2.8
Compiled using: APR 1.2.8, APR-Util 1.2.8
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
CMaurer
 
Posts: 4
Joined: 14. November 2008 10:36

Re: cross compiled apache + libphp5.so segfaults on powerpc

Postby CMaurer » 12. December 2008 13:08

I got this to work.
When doing a 'php -i' or calling phpinfo(); the cross-compiled PHP still shows a 'Balloc() allocation exceeds list boundary' error, but the reason is that php_printf() does not work for %f.
'php -i' calls
guess_timezone() in php_date.c, which calls
Code: Select all
static char* guess_timezone(const timelib_tzdb *tzdb TSRMLS_DC)

which calls
Code: Select all
php_error_docref(NULL TSRMLS_CC, E_STRICT, DATE_TZ_ERRMSG "We selected '%s' for '%s/%.1f/%s' instead", tzid, ta ? ta->tm_zone : "Unknown", ta ? (float) (ta->tm_gmtoff / 3600) : 0, ta ? (ta->tm_isdst ? "DST" : "no DST") : "Unknown");

which calls php_cverror() which calls vspprintf() which calls xbuf_format_converter() which does a
Code: Select all
fp_num = va_arg(ap, double);

when it encounters a %f although a float was passed in to php_error_docref(). I did not investigate any further.
So I changed the code above from %f to %d
Code: Select all
        php_error_docref(NULL TSRMLS_CC, E_STRICT, DATE_TZ_ERRMSG "We selected '%s' for '%s/%d/%s' instead",
            tzid,
            ta ? ta->tm_zone : "Unknown",
            ta ? ta->tm_gmtoff : 0,
            ta ? (ta->tm_isdst ? "DST" : "no DST") : "Unknown");

which fixes this.

I would sure like to know a cross-compiled php_printf() fails to work for %f!
CMaurer
 
Posts: 4
Joined: 14. November 2008 10:36


Return to Apache

Who is online

Users browsing this forum: No registered users and 22 guests