[Resolved] lsphp: failed to map segment from shared object: Cannot allocate memory

gboudreau

Well-Known Member
#1
Code:
# uname -a
Linux iwebtwo.danslereseau.com 2.6.18-194.26.1.el5xen #1 SMP Tue Nov 9 13:35:30 EST 2010 x86_64 x86_64 x86_64 GNU/Linux
PHP (5.3.3) compiled using LSWS.

Code:
# php -i | head
phpinfo()
PHP Version => 5.3.3

System => Linux iwebtwo.danslereseau.com 2.6.18-194.26.1.el5xen #1 SMP Tue Nov 9 13:35:30 EST 2010 x86_64
Build Date => Nov 16 2010 06:53:16
Configure Command =>  './configure'  '--prefix=/usr/local/lsws/lsphp5' '--with-config-file-path=/etc' '--with-pic' '--disable-rpath' '--with-pear' '--with-bz2' '--with-curl' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--enable-force-cgi-redirect' '--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-ncurses=shared' '--with-gd=shared' '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--with-ldap=shared' '--with-ldap-sasl' '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/bin/mysql_config' '--enable-dom=shared' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-xsl=shared,/usr' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr' '--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr' '--enable-json=shared' '--enable-zip=shared' '--with-readline' '--enable-dbase=shared' '--with-mcrypt=shared,/usr' '--with-mhash=shared,/usr' '--with-tidy=shared,/usr' '--enable-suhosin' '--with-litespeed'
Server API => LiteSpeed V5.4
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
When I try to load a PHP page through LSWS, the error.log says:

Code:
[16-Nov-2010 09:38:06] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lsws/lsphp5/lib/php/20090626/mbstring.so' - /usr/local/lsws/lsphp5/lib/php/20090626/mbstring.so: failed to map segment from shared object: Cannot allocate memory in Unknown on line 0
(Same error repeated for all extension I have loaded.)
2010-11-16 09:38:06.987 [STDERR] Out of memory
Trying to execute the same PHP page from the command line works fine.

Any idea what the problem is?
Is there something special that needs to be done to run LSPHP on a x86_64 machine?

*edit: I've read somewhere that suhosin could be the cause. Re-compiling PHP without it now.
*edit 2: Re-compiled without suhosin; still same problem.
 
Last edited by a moderator:

webizen

Well-Known Member
#2
how much is your system memory? it seems your lsphp5 could not load these modules as no more memory is available.

pls run lsphp5 without these modules (comment out all the extension line such as 'extension=mbstring.so') and see if it can start? and can add a few at a time?

you may also re-compile lsphp with only needed modules.
 

gboudreau

Well-Known Member
#3
I'm on a new dedicated server with more RAM (1.5GB) than my previous install which used the same modules (same php.ini). I was on Fedora before, with 1GB of RAM.

Now that I compare, I see that I compiled --with-pear, and --with-mime-magic, and without on my old server. I'll try to change those to get the exact same modules compiled and see if it helps.
 

gboudreau

Well-Known Member
#4
I was able to make a simple PHP page load by disabling/enabling the following modules:

Code:
extension=gd.so
;extension=imap.so
;extension=ldap.so
extension=mbstring.so
;extension=mysqli.so
extension=mysql.so
;extension=pdo.so
;extension=pdo_mysql.so
;extension=pdo_pgsql.so
;extension=pdo_sqlite.so
;extension=pgsql.so
;extension=soap.so
extension=json.so
;extension=zip.so
extension=dom.so
extension=xmlreader.so
;extension=xmlwriter.so
extension=xsl.so
All those modules were enabled on my previous server, where I had less RAM. Why would I need to load less module on my new server for LSWS to be able to use PHP ?

During my tests, I saw this error at one point:
Code:
PHP Fatal error: Out of memory (allocated 262144) (tried to allocate 523800 bytes) in Unknown on line 0
256kB allocated, tried to allocate another 512kB, and it failed...

My munin RAM graph looks like this: http://cl.ly/2P3Q393Y3P0U0y0P1x36
Which I think is fine; the orange part is cache, and should be usable for apps that need more RAM (I think).

Any LSWS setting I should check to see why it seems to limit the amount of RAM LSPHP can use to < 756kB ?
(I copied the conf and admin/conf dirs from my old install, to make sure I used the same settings, but maybe I messed something up.)
 

webizen

Well-Known Member
#5
loading less modules is part of troubleshooting process to see if there is anything else prevents lsws from using php.

assuming your /etc/php.ini is copied from the old server, can you check memory_limit in the phpinfo() output? is that the same in /etc/php.ini?

do you have any opcode cache setup? such as apc, xcache, eAccelerator, etc? if so, how much memory gets allocated for that?
 

gboudreau

Well-Known Member
#6
From phpinfo: memory_limit 768M (same as php.ini)
Same php.ini file on both servers.

No opcode cache enabled.

I tried to remove the 'shared' from my configure command. It didn't help.
Now I'm trying the default configure line that LSWS suggests.
 

gboudreau

Well-Known Member
#7
The default config line worked; I was able to enable all modules with a LSPHP compiled with that.
But it's missing things I need, like curl, freetype, openssl... I'm going to try to find only the ones I need (difficult, since I run a lot of PHP apps on my server, and don't know exactly what they all need), and try to compile with just that, and see if I can enable all modules again.
 
#10
lsphp itself has soft/hard limit:
External App->lsphp5:
Memory Soft Limit (bytes)
Memory Hard Limit (bytes)

increase these limit and see if it helps.
 

gboudreau

Well-Known Member
#17
Code:
# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 11896
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) unlimited
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
 

gboudreau

Well-Known Member
#19
They are all 64-bit:
Code:
# file /usr/local/lsws/lsphp5/lib/php/20090626/*.so
/usr/local/lsws/lsphp5/lib/php/20090626/bcmath.so:     ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/dba.so:        ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/dom.so:        ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/gd.so:         ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/imap.so:       ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/json.so:       ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/ldap.so:       ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/mbstring.so:   ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/mcrypt.so:     ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/mysqli.so:     ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/mysql.so:      ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/odbc.so:       ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/pdo_mysql.so:  ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/pdo_odbc.so:   ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/pdo_pgsql.so:  ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/pdo.so:        ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/pdo_sqlite.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/pgsql.so:      ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/snmp.so:       ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/soap.so:       ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/suhosin.so:    ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/tidy.so:       ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/xmlreader.so:  ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/xmlrpc.so:     ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/xmlwriter.so:  ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/xsl.so:        ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
/usr/local/lsws/lsphp5/lib/php/20090626/zip.so:        ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
 
Top