Modify

Opened 6 years ago

Last modified 3 years ago

#11065 reopened defect

(php5) php-cgi and phpfcgi get seg fault

Reported by: tm@… Owned by: developers
Priority: normal Milestone: Barrier Breaker 14.07
Component: toolchain Version: Trunk
Keywords: php5 uClibc Cc:

Description

(php5) php-cgi and php-fcgi get seg fault at the end of the script with uClibc 0.9.33, works fine with uClibc 0.9.32-git
hello.php:
<?php

print "Hello World";

?>

php-cli hello.php
Hello WorldSegmentation fault

php-fcgi hello.php
X-Powered-By: PHP/5.3.10
Content-type: text/html

Hello WorldSegmentation fault

Attachments (0)

Change History (24)

comment:1 Changed 6 years ago by tm@…

to complete:
syslog:
php-cli[2474]: segfault at b6d2d238 ip b78c0539 sp bfe87ad8 error 4 in ld-uClibc-0.9.33.so[b78bf000+7000]

comment:2 Changed 6 years ago by nbd

please try latest 0.9.33.2

comment:3 Changed 6 years ago by jao.chin@…

I have the same problem with trunck version #31858, and build it for x86 VirtualBox VDI (RAM=384M).

root@router:~# uname -a
Linux router 3.3.7 #12 Fri May 25 18:14:50 CST 2012 i686 GNU/Linux

My php test script (<?php phpinfo(); ?>) runs successfully but ended with "Segmentation fault" too.

The following log shows both in system log and kernel log :

php-cgi[2455]: segfault at b725c238 ip b779f539 sp bfc23ba8 error 4 in ld-uClibc-0.9.33.2.so[b779e000+7000]

php-cgi execution result :

root@router:~# php-cgi -v
PHP 5.3.10 (cgi-fcgi) (built: May 22 2012 16:28:39)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
Segmentation fault
root@router:~# php-cgi -m
[PHP Modules]
cgi-fcgi
Core
ctype
date
ereg
filter
gd
json
libxml
mbstring
mysql
mysqli
pcre
PDO
pdo_mysql
posix
Reflection
session
SimpleXML
SPL
standard
tokenizer
zip
zlib

[Zend Modules]

Segmentation fault

Installed packages :

lighttpd - 1.4.30-2
lighttpd-mod-cgi - 1.4.30-2
lighttpd-mod-evasive - 1.4.30-2
lighttpd-mod-fastcgi - 1.4.30-2
php5 - 5.3.10-4
php5-cgi - 5.3.10-4
php5-fastcgi - 5.3.10-4
php5-mod-ctype - 5.3.10-4
php5-mod-gd - 5.3.10-4
php5-mod-json - 5.3.10-4
php5-mod-mbstring - 5.3.10-4
php5-mod-mysql - 5.3.10-4
php5-mod-mysqli - 5.3.10-4
php5-mod-pdo - 5.3.10-4
php5-mod-pdo-mysql - 5.3.10-4
php5-mod-session - 5.3.10-4
php5-mod-simplexml - 5.3.10-4
php5-mod-tokenizer - 5.3.10-4
php5-mod-zip - 5.3.10-4
zoneinfo-asia - 2011n-1
zoneinfo-core - 2011n-1

comment:4 Changed 6 years ago by oc80z

To fix this, please back down your uClibc-0.9.33 version to uClibc-0.9.32

comment:5 Changed 5 years ago by loadrunner

how?

comment:6 Changed 5 years ago by tm@…

with current trunk (r35099)

[*] Advanced configuration options (for developers) --->[*] Toolchain Options --->uClibc Version (uClibc 0.9.32-git) ---> (X) uClibc 0.9.32-git

but only (X) uClibc 0.9.33.2
is avaliable...

I have not tested

comment:7 Changed 5 years ago by loadrunner

I downloaded uClibc 0.9.32 from an older revision, ran make menuconfig, changed uClibc version to 9.32, ran make make package/php5/clean, make package/php5/compile, but php was still compiled with 9.33.
What am I doing wrong?

comment:8 Changed 5 years ago by nbd

Did you try current trunk with uclibc 0.9.33.2? I can't reproduce the error in current trunk with my build (tested on x86 and ar71xx).

comment:9 Changed 5 years ago by loadrunner

Yes, I did.
I have r35068. (built a couple of days ago)

I still get this: (cgi and cli)

[75228.320361] php-cgi[10756]: segfault at b6f1c238 ip b77a2539 sp bf92df48 error 4 in ld-uClibc-0.9.33.2.so[b77a1000+7000]

comment:10 Changed 5 years ago by nbd

please show me the output of ./scripts/diffconfig.sh

comment:11 Changed 5 years ago by loadrunner

I made some tests and it turns out that the problem appears only when the mysql, mysqli or pdo_mysql module is loaded.

comment:12 Changed 5 years ago by loadrunner

This might be relevant:
https://bugs.launchpad.net/ubuntu/+source/php5/+bug/343870

It seems to be a problem with libmysqlclient. (v5.1)

comment:13 Changed 5 years ago by nbd

  • Resolution set to fixed
  • Status changed from new to closed

fixed in r35122

comment:14 Changed 5 years ago by anonymous

  • Resolution fixed deleted
  • Status changed from closed to reopened

A few minutes ago I compiled (including "make dirclean") and installed r35146 but it's still segfaulting.

comment:15 Changed 5 years ago by nbd

did you run ./scripts/feeds update as well?

comment:16 Changed 5 years ago by anonymous

Yes I updated the feeds as well, but looks like I wrote too early because I have a similar, but not the same segfault.

Someone from comment 3 got this:

root@router:~# php-cgi -v
PHP 5.3.10 (cgi-fcgi) (built: May 22 2012 16:28:39)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
Segmentation fault

but I get:

root@router:~# php-cgi -v
Segmentation fault

So, it doesn't run at all.
Also, only php-cgi and -fcgi are affected, not php-cli. Php-cli runs fine without any problem.
That indicates, that my segfault (which I also described in #12681 ) is different from the libmysqlclient-segfault in this ticket.

To be sure, I recompiled again with everything sql-related disabled (libmysqlclient was unselected too), but the error still persists. So yeah, looks like there's another php module or library that needs to be updated.

I will compare my php modules with the modules from guy from comment 3 later, because the source of those segfaults should be a module that I have, but he don't.

comment:17 Changed 5 years ago by Jack Yeh <jao.chin@…>

I'm the guy who wrote the comment 3. I can confirm the segfault is fixed with mysql support in the revision 35145.

root@router:~# uname -a
Linux router 3.7.2 #5 Mon Jan 14 14:02:12 CST 2013 mips GNU/Linux
root@router:~# php-cgi -v
PHP 5.4.5 (cgi-fcgi) (built: Dec 28 2012 13:18:01)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
root@router:~# php-cgi -m
[PHP Modules]
cgi-fcgi
Core
ctype
date
dio
dom
ereg
filter
gd
gettext
hash
iconv
json
libxml
mbstring
mcrypt
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
posix
Reflection
session
shmop
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

However, the performance seems not quite well in this build.

comment:18 Changed 5 years ago by anonymous

I narrowed it down to the php5 module "apc". After "rm /etc/php5/apc.ini" php-cgi and php-fcgi don't segfault anymore. That was easier than I thought. :-)

comment:19 Changed 5 years ago by oliver@…

mysqli is causing the issue here for me.

php-cli --version
'PHP 5.4.5 (cli) (built: Jan 11 2013 17:19:28)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

OpenWrt Barrier Breaker r35174

Removing it removed the segfaulting. Now I just gotta figure out why i'm not getting any output ;)

comment:20 Changed 5 years ago by oliver@…

Actually, I've installed a ton of php-mods. Here is a list that cause segfaulting when using php-cgi -m.

php-cgi: symbol 'libiconv_open': can't resolve symbol in lib '/usr/lib/php/gd.so'.
php-cgi: symbol 'php_sockets_le_socket': can't resolve symbol in lib '/usr/lib/php/libevent.so'.
Segmentation fault

(ldd also segfaults on those .so's)

Removing these two so's we get the above mentioned segfaults without reason, which is caused by mod-apc. Luckly it's the first one and also a reported one. After removing all these 4 or so libs, php doesn't segfault anymore.

comment:21 Changed 5 years ago by jra@…

I just looked into this problem. I took a virgin Attitude Adjustment .VDI and used "opkg install php5-mod-mbstring" to fetch packages from the OpenWRT download server. The resulting PHP5 install had the segfault problem. Moving /etc/php5/mbstring.ini fixed the segfault problem. Putting it back made the problem come back.

So something's wrong with the mbstring.so file.

I built php5-mod-mbstring myself to try to debug its build process. My .config showed that iconv was not automatically selected by php5-mod-mbstring:

$ grep iconv .config
# CONFIG_PACKAGE_libiconv is not set
# CONFIG_PACKAGE_libiconv-full is not set
# CONFIG_PACKAGE_iconv is not set
# CONFIG_PACKAGE_php5-mod-iconv is not set

The resulting .ipkg installed ok and fixed the segfault problem.

My belief is that on the build machine, iconv is selected, and shows up in the staging /lib directory, so that PHP modules autoconfig themselves to use it. In my build, libiconv was not available at build time, so it is not used, and the problem is avoided.

I have the same problem with PHP modules that link against mysql, and it makes sense, maybe, that the same mechanism is at work. Am building mysql + php5-mod-mysql without libconv now to see.

comment:22 Changed 4 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

comment:23 Changed 3 years ago by mhei

  • Resolution set to fixed
  • Status changed from reopened to closed

The problem describe here should be fixed with latest trunk. Please update, test and report if this issue still persists.

comment:24 Changed 3 years ago by anonymous

  • Resolution fixed deleted
  • Status changed from closed to reopened

I am still seeing this problem in the latest x86_64 build.

# php-cli -v
PHP 5.4.37 (cli) (built: Feb 18 2015 13:02:36)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
Segmentation fault

# uname -a
Linux PowercodeBMU 3.14.32 #4 SMP Fri Feb 20 13:37:29 CST 2015 x86_64 GNU/Linux

# cat /tmp/test.php
<?
echo "test";
?>

# php-cli /tmp/test.php
testSegmentation fault

Add Comment

Modify Ticket

Action
as reopened .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.