Edit report at http://bugs.php.net/bug.php?id=51216&edit=1
ID: 51216 Comment by: remco at maxserv dot nl Reported by: dtm2mcs at gmail dot com Summary: Segmentation fault when compiling PHP with PHAR Status: Open Type: Bug Package: PHAR related Operating System: Ubuntu 6.04 + CentOS 5.4 PHP Version: 5.3.2 New Comment: I can confirm that this problem exists. Compiled with apache MPM-prefork, everything went fine. Switched to MPM-worker, breaks at the same point as mentioned in this report. (Debian, Linux KPI 2.6.26-2-686 #1 SMP Tue Mar 9 17:35:51 UTC 2010 i686 GNU/Linux) Configure used for apache: ./configure --prefix=/usr/local/apache2 --enable-so --enable-auth-digest --enable-cache --enable-deflate --enable-expires --enable-headers --enable-info --enable-logio --enable-mime-magic --enable-proxy --enable-rewrite --enable-speling --enable-ssl --enable-unique-id --with-mpm=worker Configure used for PHP: './configure' '--prefix=/usr/lib/php5' '--host=x86-pc-linux-gnu' '--mandir=/usr/lib/php5/man' '--infodir=/usr/lib/php5/info' '--sysconfdir=/etc' '--cache-file=./config.cache' '--with-libdir=lib' '--with-pcre-regex=/usr' '--enable-cli' '--with-apxs2=/usr/bin/apxs2' '--with-config-file-path=/etc/php/apache2-php5' '--with-config-file-scan-dir=/etc/php/apache2-php5/ext-active' '--with-pear' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--with-curl' '--with-curlwrappers' '--enable-exif' '--enable-ftp' '--with-gettext' '--without-gmp' '--with-kerberos' '--enable-mbstring' '--with-mcrypt' '--with-mhash' '--with-mssql' '--with-openssl' '--with-openssl-dir=/usr' '--disable-pcntl' '--without-pgsql' '--without-pspell' '--without-recode' '--disable-shmop' '--with-snmp' '--enable-soap' '--enable-sockets' '--without-sybase-ct' '--disable-sysvmsg' '--disable-sysvsem' '--disable-sysvshm' '--without-tidy' '--disable-wddx' '--with-xmlrpc' '--with-xsl' '--enable-zip' '--with-zlib' '--disable-debug' '--without-enchant' '--disable-intl' '--enable-phar' '--enable-dba' '--without-cdb' '--without-db4' '--disable-flatfile' '--with-gdbm' '--disable-inifile' '--without-qdbm' '--with-freetype-dir=/usr' '--with-t1lib=/usr' '--disable-gd-jis-conv' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--with-gd' '--with-imap' '--with-imap-ssl' '--with-ldap' '--without-ldap-sasl' '--with-mysql=/usr/local/mysql' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-unixODBC=/usr' '--without-adabas' '--without-birdstep' '--without-dbmaker' '--without-empress' '--without-esoob' '--without-ibm-db2' '--without-iodbc' '--without-sapdb' '--without-solid' '--with-pdo-dblib' '--with-pdo-mysql=/usr' '--with-pdo-odbc=unixODBC,/usr' '--without-pdo-pgsql' '--with-readline' '--without-libedit' '--without-mm' '--without-sqlite' Building without phar works, but then 'make install' fails with a segmentation fault as well. Previous Comments: ------------------------------------------------------------------------ [2010-04-09 23:18:38] holderm at lycos dot com It looks like it's more than a phar problem. I can build it rith phar disabled but it still won't run anything other than the --version option. Build complete. Don't forget to run 'make test'. /app/psoft/devl/packages/php/php-5.3.2/ hdlmpdu4/blk10.1/dev > make test Build complete. Don't forget to run 'make test'. Segmentation Fault - core dumped make: [test] Error 139 (ignored) /app/psoft/devl/packages/php/php-5.3.2/ hdlmpdu4/blk10.1/dev > ll ./sapi/cli/php -rwxr-xr-x 1 lmpjob lmpjob 18524408 Apr 9 16:25 ./sapi/cli/php /app/psoft/devl/packages/php/php-5.3.2/ hdlmpdu4/blk10.1/dev > ./sapi/cli/php --version PHP 5.3.2 (cli) (built: Apr 8 2010 18:07:52) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies ------------------------------------------------------------------------ [2010-04-09 22:21:18] holderm at lycos dot com I've got a workaround. The problem seems to be that the build_precommand.php script cannot run on systems that do not have a working version of php. I think the Makefile is doing this for me already but just to be sure I tried changing the shebang from #!/usr/bin/php to my local #!/app/psoft/devl/packages/php/php-5.3.2/sapi/cli/php (based on what I thought the Makefile was doing). I kept running it from the command line and getting things like this (I was adding my own debugging info on lines that begin with // ): /app/psoft/devl/packages/php/php-5.3.2/ext/phar/ hdlmpdu4/blk10.1/dev > ./build_precommand.php <?php /** @file phar.php * @ingroup Phar * @brief class Phar Pre Command * @author Marcus Boerger * @date 2007 - 2008 * * Phar Command */ foreach(array("SPL", "Reflection", "Phar") as $ext) { if (!extension_loaded($ext)) { echo "$argv[0] requires PHP extension $ext.\n"; exit(1); } } if (!class_exists('DirectoryTreeIterator', 0)) { // name == DirectoryTreeIterator // file(dirname('__FILE__') . '/phar/' . strtolower('DirectoryTreeIterator') . '.inc'); // g == __FILE__/phar/$name.inc Segmentation Fault(coredump) Finally I decided to bring over a working php executable from another server and give it a try: /app/psoft/devl/packages/php/php-5.3.2/ext/phar/ hdlmpdu4/blk10.1/dev > which php /app/psoft/devl/bin/php /app/psoft/devl/packages/php/php-5.3.2/ext/phar/ hdlmpdu4/blk10.1/dev > /app/psoft/devl/bin/php --version PHP 5.0.2 (cli) (built: Oct 21 2004 17:00:20) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.2, Copyright (c) 1998-2004 Zend Technologies /app/psoft/devl/packages/php/php-5.3.2/ext/phar/ hdlmpdu4/blk10.1/dev > ./build_precommand.php <?php /** @file phar.php * @ingroup Phar * @brief class Phar Pre Command * @author Marcus Boerger * @date 2007 - 2008 * * Phar Command */ foreach(array("SPL", "Reflection", "Phar") as $ext) { if (!extension_loaded($ext)) { echo "$argv[0] requires PHP extension $ext.\n"; exit(1); } } if (!class_exists('DirectoryTreeIterator', 0)) { // name == DirectoryTreeIterator // file(dirname('__FILE__') . '/phar/' . strtolower('DirectoryTreeIterator') . '.inc'); // g == __FILE__/phar/$name.inc // f == Array // f == Array // c == 53 /** @file directorytreeiterator.inc * @ingroup Examples * @brief class DirectoryTreeIterator * @author Marcus Boerger * @date 2003 - 2008 * * SPL - Standard PHP Library */ /** @ingroup Examples * @brief DirectoryIterator to generate ASCII graphic directory trees * @author Marcus Boerger * @version 1.1 */ class DirectoryTreeIterator extends RecursiveIteratorIterator { /** Construct from a path. * @param $path directory to iterate */ function __construct($path) So, the problem is that the php executable that's built as an interem version for running the build_precommand.php script is not able to use the strtolower() function or the dirname() function (as far as my testing got, it bombed on each of those isolated cases). I was able to make a kludge workaround by modifing the Makefile replacing $(PHP_PHARCMD_EXECUTABLE) with my executable, but the next step failed (target ext/phar/phar.phar:). So I had to disable phar. ------------------------------------------------------------------------ [2010-04-09 00:22:37] holderm at lycos dot com The problem is in build_precommand.php. When I run it it gets to the open curly brace and churns for a couple seconds, then it Seg faults. I'm not sure how to fix it but will try changing it. /app/psoft/devl/packages/php/php-5.3.2/ext/phar/ hdlmpdu4/blk10.1/dev > ./build_precommand.php <?php /** @file phar.php * @ingroup Phar * @brief class Phar Pre Command * @author Marcus Boerger * @date 2007 - 2008 * * Phar Command */ foreach(array("SPL", "Reflection", "Phar") as $ext) { if (!extension_loaded($ext)) { echo "$argv[0] requires PHP extension $ext.\n"; exit(1); } } if (!class_exists('DirectoryTreeIterator', 0)) { Segmentation Fault(coredump) ------------------------------------------------------------------------ [2010-04-07 23:34:47] holderm at lycos dot com I'm getting the same thing with Solaris 10 and gcc 4.4.3. It seems the Makefile is not generating a full ext/phar/phar.php (when compared to ext/phar/phar/phar.php). The code ends with an open curly brace: Generating phar.php Segmentation Fault - core dumped make: *** [ext/phar/phar.php] Error 139 /app/psoft/devl/packages/php/php-5.3.2/ hdlmpdu4/blk10.1/dev > ll ext/phar/phar.php -rw-r--r-- 1 lmpjob lmpjob 351 Apr 7 16:10 ext/phar/phar.php /app/psoft/devl/packages/php/php-5.3.2/ hdlmpdu4/blk10.1/dev > ll ext/phar/phar/phar.php -rwxr-xr-x 1 lmpjob lmpjob 992 Aug 1 2008 ext/phar/phar/phar.php /app/psoft/devl/packages/php/php-5.3.2/ hdlmpdu4/blk10.1/dev > cat ext/phar/phar.php <?php /** @file phar.php * @ingroup Phar * @brief class Phar Pre Command * @author Marcus Boerger * @date 2007 - 2008 * * Phar Command */ foreach(array("SPL", "Reflection", "Phar") as $ext) { if (!extension_loaded($ext)) { echo "$argv[0] requires PHP extension $ext.\n"; exit(1); } } if (!class_exists('DirectoryTreeIterator', 0)) { As far as I can tell this part of the Makefile is where the problem is: ext/phar/phar.php: /app/psoft/devl/packages/php/php-5.3.2/ext/phar/build_precommand.php /app/psoft/devl/packages/php/php-5.3.2/ext/phar/phar/*.inc /app/psoft/devl/packages/php/php-5.3.2/ext/phar/phar/*.php $(SAPI_CLI_PATH) -...@echo "Generating phar.php" @$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) /app/psoft/devl/packages/php/php-5.3.2/ext/phar/build_precommand.php > ext/phar/phar.php My configure options were: /app/psoft/devl/packages/php/php-5.3.2/ hdlmpdu4/blk10.1/dev > cat config.nice #! /bin/sh # # Created by configure './configure' \ '--prefix=/app/psoft/scripts/pkg/php5' \ '--enable-cli' \ '--disable-cgi' \ '--with-bz2' \ '--with-zlib' \ '--with-png-dir=/app/psoft/scripts/pkg/png-1.4.1' \ '--with-gd' \ '--with-oci8=/app/oracle/product/10.2.0' \ "$@" ------------------------------------------------------------------------ [2010-03-30 17:39:38] tony at tonybibbs dot com Same issue on 32bit Ubuntu 9.10 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=51216 -- Edit this bug report at http://bugs.php.net/bug.php?id=51216&edit=1