# php 5.1.2 cli segfault [solved]

## cdf

Just upgraded to php 5.1.2 yesterday.  Today I noticed cli isn't working.  I get the following errors:

```
# php -v

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/lib/php/extensions/no-debug-zts-20050922/openssl.so' - /usr/lib/php5/lib/php/extensions/no-debug-zts-20050922/openssl.so: cannot open shared object file: No such file or directory in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/lib/php/extensions/no-debug-zts-20050922/zip.so' - /usr/lib/php5/lib/php/extensions/no-debug-zts-20050922/zip.so: cannot open shared object file: No such file or directory in Unknown on line 0

PHP 5.1.2-gentoo (cli) (built: Mar 16 2006 12:20:00)

Copyright (c) 1997-2006 The PHP Group

Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

Segmentation fault

```

Neither zip.so nor openssl.so exist in the directories it's looking for them.  But there are over a dozen other extensions which seem to be working fine.  I didn't change php.ini or any USE flags either.

I ran revdep-rebuild and nothing came up.  I re-emerged php5 anyway but still the same problem.

I'm out of ideas.   :Sad:   Can anyone help?Last edited by cdf on Mon May 01, 2006 9:48 pm; edited 1 time in total

----------

## kashani

If you're using the 2006.0 profile, +fastbuild was added to dev-lang/php. Instead of building the module and the cli seperately it attempts to build them at the same time. You may want to specify -fastbuild and rebuild assuming any of this applies.

You might also try deleting the zip.ini and openssl.ini that are int he /etc/php dirs... I'd had issues with them in the past.

kashani

----------

## cdf

Deleted:

```
/etc/php/cli-php5/ext/openssl.ini

/etc/php/cli-php5/ext/zip.ini

/etc/php/cli-php5/ext-active/openssl.ini

/etc/php/cli-php5/ext-active/zip.ini
```

And now I don't get the errors about failed extensions.   :Smile:   However, it still says "Segmentation fault" after executing my script.  Example script test.php:

```
#!/usr/bin/php

<?php

echo "Hello world.";

?>

```

But I get:

```
# php test.php

Hello world.Segmentation fault

```

Any further ideas?  At least it will run my scripts now...

----------

## kashani

what's an emerge -pv dev-lang/php look like?

kashani

----------

## cdf

```
[ebuild   R   ] dev-lang/php-5.1.2  USE="apache2 bcmath berkdb bzip2 cjk cli crypt curl dba exif ftp gd gdbm iconv imap ldap mysql mysqli ncurses nls pcntl pcre posix readline sasl session sharedext simplexml sockets ssl threads tidy truetype xml xmlrpc xpm xsl zip zlib -adabas -apache -birdstep -calendar -cdb -cgi -ctype -curlwrappers -db2 -dbase -dbmaker -debug -discard-path -doc -empress -empress-bcs -esoob -fastbuild -fdftk -filepro -firebird -flatfile -force-cgi-redirect -frontbase -gd-external -gmp -hardenedphp -hash -hyperwave-api -informix -inifile -interbase -iodbc -ipv6 -java-external -kerberos -libedit -mcve -memlimit -mhash -ming -msql -mssql -oci8 -oci8-instant-client -odbc -pdo -pdo-external -pic -postgres -qdbm -recode -reflection -sapdb -sharedmem -snmp -soap -solid -spell -spl -sqlite -sybase -sybase-ct -sysvipc -tokenizer -vm-goto -vm-switch -wddx -xmlreader -xmlwriter -yaz" 0 kB

Total size of downloads: 0 kB

```

----------

## cdf

Things got even stranger.  I was working on some PHP stuff through CGI/Apache and suddenly all PHP scripts would die without writing any output.  I could live with segfaulting CLI but not CGI mode!  So I downgraded.

```
# echo dev-lang/php-5.2.1 >> /etc/portage/package.mask

# emerge -v1a dev-lang/php

```

I'm back to 5.0.x now and things are working fine, both CLI and CGI.

But thanks for trying to help, Kashani.   :Smile: 

----------

## kashani

It's possible that threads are causing you issues, I missed that before. In any here are the use flags I use with 5.1.2. recode and readline seemed to be problematic for me in 5.1.1 which is why they are still out.

dev-lang/php                    -fastbuild -force-cgi-redirect -readline -recode -soap -threads bcmath cli ctype curl dba exif flatfile gd hardenedphp hash iconv libedit jpeg mhash mysql pcre pdo pear posix session simplexml spl tiff tokenizer truetype xml xmlrpc xsl zlib

kashani

----------

## cdf

Thanks again.  I'll try to remember that next time I upgrade.   :Smile: 

----------

## kashani

For the hell of it and since I'm playing with PHP USE flags trying to get a smaller binary I pulled libedit out and added in readline. Still works fine for me... ah well. 

kashani

----------

## cappaberra

I'm having the same issues... I'm going to play with this a bit and see if I can figure it out.

-cappaberra

----------

## Aries-Belgium

I just had the same problem and I would like to share the solution with you guys:

I got the error that zip.so wasn't found, so I checked portage to see what package zip.so belongs to:

```
equery belongs zip.so
```

Found out that it was dev-php5/pecl-zip

I emerged it again and the error was resolved ...

I hope this is helpfull for you ...

----------

## cappaberra

Here's what my errors look like:

```
user@linuxbox$ php -v

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/lib/php/extensions/no-debug-zts-20050922/openssl.so' - /usr/lib/php5/lib/php/extensions/no-debug-zts-20050922/openssl.so: cannot open shared object file: No such file or directory in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/lib/php/extensions/no-debug-zts-20050922/xmlreader.so' - /usr/lib/php5/lib/php/extensions/no-debug-zts-20050922/xmlreader.so: cannot open shared object file: No such file or directory in Unknown on line 0

PHP 5.1.2-gentoo (cli) (built: Mar 19 2006 21:11:06)

Copyright (c) 1997-2006 The PHP Group

Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

user@linuxbox$
```

After executing the equery commands, here's the result:

```
user@linuxbox$ equery belongs xmlreader.so

[ Searching for file(s) xmlreader.so in *... ]

user@linuxbox$ equery belongs openssl.so

[ Searching for file(s) openssl.so in *... ]

dev-lang/ruby-1.8.4-r1 (/usr/lib/ruby/1.8/i686-linux/openssl.so)

user@linuxbox$
```

I re-emerged ruby, but that didn't help... :-\  I tried running the above commands as root too and that didn't make a difference.  Any other suggestions to help with openssl or xmlreader?  I'm thinking about re-emerging php with xmlreader disabled since I never use it... but I need openssl. Ideas? Thoughts? Best wishes? Free beer?  :Wink: 

----------

## cappaberra

hmm... just found a related thread.  Very interesting indeed... check it out!

https://forums.gentoo.org/viewtopic-t-428132-highlight-nodebugzts20050922.html

-cappaberra

----------

## llongi

@cappaberra: your two errors actually come I think from two different issues.

The first, the one about openssl.so, is because with PHP 5.1.2, we've made the openssl extension to never be shared and to always be compiled directly in the PHP binary, since it was causing problems when shared. Now Portage never deletes/changes files in /etc, and those files are the ones that control which PHP extensions shall get loaded or not, so there still is the file that says "load the shared openssl extension", but the extension itself doesn't anymore exist. Just execute the following to fix that:

```
rm -f /etc/php/*-php5/ext-active/openssl.ini && rm -f /etc/php/*-php5/ext/openssl.ini
```

For the xmlreader issue, the causes can be two. If you compiled PHP 5.1.2 with the "xmlreader" USE flag disabled, then the problem is the same as above and just removing the files as above (xmlreader.ini instead of openssl.ini) should solve it.

If this is not the case, the other cause could be that your extension_dir value in php.ini doesn't match the real one (this can happen if you don't etc-update correctly, or sometimes with dispatch-conf it seems). Check what the directory on your system really is (ls /usr/lib/php5/lib/php/extensions/), see the name of the directory there, and check if it's the same you see as extension_dir value in your PHP5's php.inis.

----------

## cappaberra

CHTEKK, thanks for your response!  Your detailed explanation does sound correct.  Just deleting the files does solve the problem, and I checked my extensions directory many-a-time and it is correct..  Is there any documentation somewhere about what previous dynamic extensions are now compiled into the binary?  

Thanks,

cappaberra

----------

## llongi

 *cappaberra wrote:*   

> Is there any documentation somewhere about what previous dynamic extensions are now compiled into the binary?

 

No, not really. Watch planet.gentoo.org where I normally announce big changes to the PHP packages, as well as upcoming updates etc. on my blog, in the future it's planned to create an utility that should help to ease the management of turning extensions on/off, and that checks which extensions really exist/are available and disables the ones that are not (basically a tool to manage the symlinks from ext-active/ to ext/).

----------

## cdf

Taking a wild guess based on another forum thread, I removed the 'tidy' USE flag and recompiled, and the segfault went away.  I had to remove the tidy.ini files inside /etc/php/*-php5/* however.  Portage didn't remove them automatically (due to /etc being protected?).

----------

## dfannin

I was seeing the same problem with both php4/5 (running as cgi builds in apache2).  PHP page performance was deathly slow , and the apache error log was showing:

```

[Mon Jun 05 12:03:07 2006] [error] [client 192.168.10.3] PHP Warning:  Unknown(): Unable to load dynamic library '/usr/lib/php4/lib/php/extensions/no-debug-zts-20020429/ldap.so' - /usr/lib/php4/lib/php/extensions/no-debug-zts-20020429/ldap.so: cannot open shared object file: No such file or directory in Unknown on line 0

[Mon Jun 05 12:03:10 2006] [error] [client 192.168.10.3] PHP Warning:  Unknown(): Unable to load dynamic library '/usr/lib/php4/lib/php/extensions/no-debug-zts-20020429/openssl.so' - /usr/lib/php4/lib/php/extensions/no-debug-zts-20020429/opelnssl.so: cannot open shared object file: No such file or directory in Unknown on line 0

```

An easy way to see this is to run php -v using the cli command.  

I deleted the related .ini files for ldap and openssl by using the follwing commands:

```

rm -i /etc/php/*php*/ext-active/openssl.ini

rm -i /etc/php/*php*/ext/openssl.ini

rm -i /etc/php/*php*/ext-active/ldap.ini

rm -i /etc/php/*php*/ext/ldap.ini

```

This cleared the error messages, but I am still getting slow performace (but no error messages).  revdep-rebuild didn't catch anything,

I also recompiled php5 without tidy (-tidy).     Apache now starts, but php4 is still very low on initalization.

WTF!  I wish the php folks had given a heads up around this change.  This will cause a lot of working systems to break.

----------

## su

 *Aries-Belgium wrote:*   

> I just had the same problem and I would like to share the solution with you guys:
> 
> I got the error that zip.so wasn't found, so I checked portage to see what package zip.so belongs to:
> 
> ```
> ...

 

I have the same thing, but with php-5.2.1-r3 and pecl-fileinfo

When trying to remerge 'fileinfo', however, I get the following compile errors:

```
....

 i686-pc-linux-gnu-gcc -I. -I/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3 -DPHP_ATOM_INC -I/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/include -I/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/main -I/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3 -I/usr/lib/php5/include/php -I/usr/lib/php5/include/php/main -I/usr/lib/php5/include/php/TSRM -I/usr/lib/php5/include/php/Zend -I/usr/lib/php5/include/php/ext -I/usr/lib/php5/include/php/ext/date/lib -DHAVE_CONFIG_H -O3 -march=pentium4 -funroll-loops -pipe -c /var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c  -fPIC -DPIC -o .libs/fileinfo.o

/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c:124:42: macro "ZEND_ME_MAPPING" requires 4 arguments, but only 3 given

/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c:125:49: macro "ZEND_ME_MAPPING" requires 4 arguments, but only 3 given

/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c:125: error: `ZEND_ME_MAPPING' undeclared here (not in a function)

/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c:125: error: initializer element is not constant

/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c:125: error: (near initialization for `finfo_class_functions[0]')

/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c:125: error: syntax error before "ZEND_ME_MAPPING"

/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c:126:41: macro "ZEND_ME_MAPPING" requires 4 arguments, but only 3 given

/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c:127:45: macro "ZEND_ME_MAPPING" requires 4 arguments, but only 3 given

/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c:128: error: initializer element is not constant

/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c:128: error: (near initialization for `finfo_class_functions[1]')

/var/tmp/portage/pecl-fileinfo-1.0.3/work/Fileinfo-1.0.3/fileinfo.c:129: error: syntax error before '}' token

make: *** [fileinfo.lo] Error 1

!!! ERROR: dev-php5/pecl-fileinfo-1.0.3 failed.

Call stack:

  ebuild.sh, line 1546:   Called dyn_compile

  ebuild.sh, line 937:   Called src_compile

  ebuild.sh, line 1255:   Called php-ext-pecl-r1_src_compile

  php-ext-pecl-r1.eclass, line 38:   Called php-ext-source-r1_src_compile

  php-ext-source-r1.eclass, line 49:   Called die

!!! Unable to make code

!!! If you need support, post the topmost build error, and the call stack if relevant.

```

Any help? Much appreciated, thank you.

----------

## su

Never mind. I came right installing pecl-fileinfo-1.0.4 instead using 'ACCEPT_KEYWORDS="~x86"'

Thanks anyway for all the pointers in this thread, it at least led me in the right direction.

Ciao.

----------

