From: baco at infomaniak dot ch Operating system: Linux Debian Sarge PHP version: 5.1.4 PHP Bug Type: XML related Bug description: Segfault on xml_parser_create() call
Description: ------------ PHP5 Segmentation fault when a script call xml_parser_create() under Apache but not when called from the CLI ?!? $ wget -O- http://.../xml.php => Crash of Apache thread HTTP request sent, awaiting response... End of file while parsing headers. Retrying. child pid ... exit signal Segmentation fault (11) $ php xml.php => result OK Reproduce code: --------------- PHP Code to reproduce the segmentation fault inside Apache $file = "data.xml"; $data = ''; if (!($fp = fopen($file, "r"))) { die("could not open XML input"); } while (!feof($fp)) { $data .= fread($fp, 8192); } fclose($fp); $xml_parser = xml_parser_create("ISO-8859-1"); # crash at this point xml_parse_into_struct($xml_parser, $data, $vals, $index); xml_parser_free($xml_parser); print_r($vals); Expected result: ---------------- Expected to return on Apache but only output this when I call the script from PHP CLI. Array ( [0] => Array ( ... ) ... ) Actual result: -------------- N.B. php.ini and php-cli.ini are the same. ldd on php cli and on libphp5.so both use same libxml2 from Debian Sarge. Result (gdb) continue Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1210239712 (LWP 28800)] 0x0808b14c in XML_ParserFree () strace open("/home/www/29212ea8a58d20e52ba0886bd64685bb/web/test-xml/data.xml", O_RDONLY) = 7 fstat64(7, {st_mode=S_IFREG|0644, st_size=113, ...}) = 0 lseek(7, 0, SEEK_CUR) = 0 read(7, "<?xml version=\"1.0\" encoding=\"IS"..., 8192) = 113 read(7, "", 8192) = 0 close(7) = 0 --- SIGSEGV (Segmentation fault) @ 0 (0) --- chdir("/opt/apache") = 0 rt_sigaction(SIGSEGV, {SIG_DFL}, {SIG_DFL}, 8) = 0 getpid() = 28871 kill(28871, SIGSEGV) = 0 sigreturn() = ? (mask now []) --- SIGSEGV (Segmentation fault) @ 0 (0) --- PHP Compiled with './configure' '--prefix=/opt/php' '--mandir=/usr/share/man' '--with-apxs=/opt/apache/bin/apxs' '--disable-cgi' '--with-config-file-path=/opt/php/lib' '--disable-sigchild' '--disable-ipv6' '--disable-all' '--enable-libxml' '--with-libxml-dir' '--with-openssl' '--with-kerberos' '--with-pcre-regex' '--with-zlib' '--with-zlib-dir' '--enable-bcmath' '--enable-calendar' '--enable-ctype' '--with-curl' '--enable-dom' '--enable-exif' '--enable-ftp' '--with-openssl-dir' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-xpm-dir' '--with-ttf' '--with-freetype-dir' '--enable-gd-native-ttf' '--with-gettext' '--with-gmp' '--with-iconv' '--with-imap' '--with-imap-ssl' '--enable-mbstring' '--enable-mbregex' '--with-mcrypt' '--with-mhash' '--with-mysql=/opt/misc/mysql' '--with-mysqli=/opt/misc/mysql/bin/mysql_config' '--enable-pdo' '--with-pdo-mysql=/opt/misc/mysql' '--enable-posix' '--enable-session' '--enable-simplexml' '--enable-soap' '--enable-spl' '--with-tidy' '--enable-tokenizer' '--enable-wddx' '--enable-xml' '--with-libexpat-dir' '--with-xmlrpc' '--with-iconv-dir' '--with-xsl' '--with-pear' '--enable-memory-limit' '--enable-zend-multibyte' '--with-ming=/opt/misc/ming' '--enable-debug' -- Edit bug report at http://bugs.php.net/?id=38017&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38017&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38017&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38017&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38017&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38017&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38017&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38017&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38017&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38017&r=support Expected behavior: http://bugs.php.net/fix.php?id=38017&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38017&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38017&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38017&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38017&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38017&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38017&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38017&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38017&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38017&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38017&r=mysqlcfg