PHP 5.2.5-pl1-gentoo (cli) segfaults parsing XML Reproducible: Always Steps to Reproduce: 1. php foo.php Actual Results: <b>Segmentation fault Expected Results: Parsed the XML. It works on another box. I have tried to work out what is different - but (obviously) failed. foo.xml: <?xml version="1.0"?> <foo> <bar>2</bar> <bar>3</bar> </foo> foo.php: <?php $file = "foo.xml"; function contents($parser, $data){ echo $data; } function startTag($parser, $data){ echo "<b>"; } function endTag($parser, $data){ echo "</b><br />"; } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startTag", "endTag"); xml_set_character_data_handler($xml_parser, "contents"); $fp = fopen($file, "r"); $data = fread($fp, 800); if(!(xml_parse($xml_parser, $data, feof($fp)))){ die("Error on line " . xml_get_current_line_number($xml_parser)); } xml_parser_free($xml_parser); fclose($fp); ?> dev-lang/php-5.2.5-r1 dev-libs/libxml2-2.6.30 dev-libs/expat-2.0.1
Portage 2.1.2.2 (hardened/x86/2.6, gcc-3.4.6, glibc-2.5-r4, 2.6.19-gentoo-r5-wirefree i686) ================================================================= System uname: 2.6.19-gentoo-r5-wirefree i686 Intel(R) Pentium(R) III CPU family 1266MHz Gentoo Base System release 1.12.9 Timestamp of tree: Thu, 13 Dec 2007 03:46:01 +0000 app-shells/bash: 3.1_p17 dev-java/java-config: 1.3.7, 2.0.32 dev-lang/python: 2.4.3-r4 dev-python/pycrypto: 2.0.1-r5 sys-apps/baselayout: 1.12.9 sys-apps/sandbox: 1.2.17 sys-devel/autoconf: 2.13, 2.61 sys-devel/automake: 1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10 sys-devel/binutils: 2.17 sys-devel/gcc-config: 1.3.14 sys-devel/libtool: 1.4.3-r3, 1.5.22 virtual/os-headers: 2.6.17-r2 ACCEPT_KEYWORDS="x86" CBUILD="i686-pc-linux-gnu" CFLAGS="-O3 -march=pentium3 -fprefetch-loop-arrays -funroll-loops -pipe" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc" CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo" CXXFLAGS="-O3 -march=pentium3 -fprefetch-loop-arrays -funroll-loops -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="distlocks metadata-transfer sandbox sfperms strict" GENTOO_MIRRORS="http://gentoo.blueyonder.co.uk/" PKGDIR="/usr/portage/packages" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" SYNC="rsync://192.168.32.20/gentoo-portage" USE="berkdb cracklib crypt flash gd-external hardened innodb mbox memlimit nls pam pic readline ssl tcpd urandom x86 zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="apm ark chips cirrus cyrix dummy fbdev glint i128 i740 i810 imstt mach64 mga neomagic nsc nv r128 radeon rendition s3 s3virge savage siliconmotion sis sisusb tdfx tga trident tseng v4l vesa vga via vmware voodoo" Unset: CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, MAKEOPTS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY I don't want to update world if at all possible. I'd rather work out what the problem is, and fix just that.
Shrug, works perfectly fine here. We need emerge -pv php output and a backtrace... http://www.gentoo.org/proj/en/qa/backtraces.xml $ php foo.php <b> <b>2</b><br /> <b>3</b><br /> </b><br /> [ebuild R ] dev-lang/php-5.2.5-r1 USE="-adabas -apache2 bcmath berkdb -birdstep bzip2 calendar -cdb cgi -cjk cli -concurrentmodphp crypt ctype curl curlwrappers -db2 -dbase -dbmaker -debug discard-path -doc -empress -empress-bcs -esoob exif fastbuild -fdftk filter -firebird flatfile force-cgi-redirect -frontbase ftp gd -gd-external gdbm gmp hash iconv -imap inifile -interbase -iodbc ipv6 -java-external json -kerberos -ldap -ldap-sasl -libedit -mcve mhash -msql -mssql -mysql -mysqli ncurses nls -oci8 -oci8-instant-client odbc pcntl pcre pdo -pic posix -postgres -qdbm readline -recode reflection -sapdb session sharedext -sharedmem simplexml -snmp soap sockets -solid spell spl sqlite ssl -suhosin -sybase -sybase-ct sysvipc threads -tidy tokenizer truetype unicode wddx xml xmlreader xmlrpc xmlwriter xpm xsl -yaz -zip zip-external zlib"
Also, don't ever use -O3 on hardened, and remove -fprefetch-loop-arrays -funroll-loops from your C[XX]FLAGS.
I know it works fine. Just not on this box/install. [ebuild R ] dev-lang/php-5.2.5-r1 USE="apache2 berkdb bzip2 cgi cli crypt gd-external nls pcre pic postgres session ssl xml zlib -adabas -bcmath -birdstep -calendar -cdb -cjk -concurrentmodphp -ctype -curl -curlwrappers -db2 -dbase -dbmaker -debug -discard-path -doc -empress -empress-bcs -esoob -exif -fastbuild -fdftk -filter -firebird -flatfile -force-cgi-redirect -frontbase -ftp -gd -gdbm -gmp -hash -iconv -imap -inifile -interbase -iodbc -ipv6 -java-external -json -kerberos -ldap -ldap-sasl -libedit -mcve -mhash -msql -mssql -mysql -mysqli -ncurses -oci8 (-oci8-instant-client) -odbc -pcntl -pdo -posix -qdbm -readline -recode -reflection -sapdb -sharedext -sharedmem -simplexml -snmp -soap -sockets -solid -spell -spl -sqlite -suhosin -sybase -sybase-ct -sysvipc -threads -tidy -tokenizer -truetype -unicode -wddx -xmlreader -xmlrpc -xmlwriter -xpm -xsl -yaz -zip -zip-external" 0 kB I'll recompile PHP with those new CFLAGS, etc, and do a backtrace. For your info, this is the emerge info from the box that works. Portage 2.1.2.9 (hardened/x86/2.6, gcc-3.4.6, glibc-2.5-r4, 2.6.20-vs2.2.0-gentoo i686) ================================================================= System uname: 2.6.20-vs2.2.0-gentoo i686 Intel(R) Pentium(R) III CPU family 1133MHz Gentoo Base System release 1.12.9 Timestamp of tree: Thu, 13 Dec 2007 03:46:01 +0000 distcc 2.16 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled] app-shells/bash: 3.1_p16 dev-lang/python: 2.4.4-r6 dev-python/pycrypto: 2.0.1-r5 sys-apps/baselayout: 1.12.9-r2 sys-apps/sandbox: 1.2.17 sys-devel/autoconf: 2.13, 2.61 sys-devel/automake: 1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10 sys-devel/binutils: 2.17-r1 sys-devel/gcc-config: 1.3.13-r2 sys-devel/libtool: 1.4.3-r3, 1.5.18-r1 virtual/os-headers: 2.6.21 ACCEPT_KEYWORDS="x86" CBUILD="i686-pc-linux-gnu" CFLAGS="-march=pentium3 -O2 -pipe -fomit-frame-pointer" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /var/bind" CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild" CXXFLAGS="-march=pentium3 -O2 -pipe -fomit-frame-pointer" DISTDIR="/usr/portage/distfiles" FEATURES="distlocks metadata-transfer sandbox sfperms strict" GENTOO_MIRRORS="http://gentoo.blueyonder.co.uk/" PKGDIR="/usr/portage/packages" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage" USE="3ds berkdb cracklib crypt ecc flash gd-external hardened imap logrotate lzo maildir midi mozsvg nls pam pic quotas readline ssl static unicode urandom x86 xfs xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="apm ark chips cirrus cyrix dummy fbdev glint i128 i740 i810 imstt mach64 mga neomagic nsc nv r128 radeon rendition s3 s3virge savage siliconmotion sis sisusb tdfx tga trident tseng v4l vesa vga via vmware voodoo" Unset: CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, MAKEOPTS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
Hello. Jakub, thanks for your help with the CFLAGS. I've set them, and recompiled Apache, PHP, libxml2, and various others, and it now works. This box was obviously one I switched from standard to hardened, and had old CFLAGS. Perhaps a warning could be issued in emerge if it detects "strange" flags? Anyway, thanks.