|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-10-18 00:42 UTC] i dot oppenheim at xs4all dot nl
Description:
------------
preg_replace crashes on long strings.
My Configure Line:
./configure --prefix=/opt/php --with-apxs \
--with-mysql=/usr --with-zlib=/usr --with-png-dir=/usr\
--with-bz2 --with-t1lib --with-dom --with-ncurses\
--with-readline --enable-calendar --with-gd\
--with-freetype-dir --with-ttf --enable-gd-native-ttf\
--with-jpeg-dir --with-xpm-dir --with-tiff-dir=/usr\
--enable-exif --with-iconv --enable-sockets\
--with-db2 --enable-dba --with-openssl --disable-cgi
Reproduce code:
---------------
#!/usr/bin/env php
<?php
changeMsg ("http://www.sicodel.com/ct.txt") ;
function changeMsg ($file) {
$txt = file_get_contents ($file) ;
$txt = preg_replace (
"[Hosted by Shamash:(.|\n)*</pre>]",
"</pre>",
$txt
) ;
} # changeMsg
?>
Actual result:
--------------
Segmentation Fault!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 19:00:01 2025 UTC |
I reconfigured PHP with --enable-debug. Here is a fragment of the requested gdb backtrace (in total 8MB large!): Core was generated by `php-dbg ./tst.php'. Program terminated with signal 11, Segmentation fault. #0 0x080d915d in match ( eptr=0x82e5603 "m. Free membership via\n> <a href=\"http://www.myjewish learning.com/shamash", '-' <repeats 24 times>, "\">http://www.myjewishlearning.c om/shamash", '-' <repeats 24 times>, "</a>\n> hanashir (at) shamash(d"..., ecode=0x82ca027 "\v=", offset_top=4, md=0xbfffce1c, ims=0, eptrb=0xbf8001c4, flags=2) at /opt/php/src/php/ext/pcre/pcrelib/pcre.c:5484 5484 { #0 0x080d915d in match ( eptr=0x82e5603 "m. Free membership via\n> <a href=\"http://www.myjewish learning.com/shamash", '-' <repeats 24 times>, "\">http://www.myjewishlearning.c om/shamash", '-' <repeats 24 times>, "</a>\n> hanashir (at) shamash(d"..., ecode=0x82ca027 "\v=", offset_top=4, md=0xbfffce1c, ims=0, eptrb=0xbf8001c4, flags=2) at /opt/php/src/php/ext/pcre/pcrelib/pcre.c:5484 <snip> #21813 0x080e0faf in php_pcre_replace ( regex=0x82d63e4 "[Hosted by Shamash:(.|\n)*</pre>]", regex_len=32, subject=0x82de53c "<!-- MHonArc v2.6.8 -->\n<!--X-Subject: [HANASHIR:15052] Re: cantorial certification(long) -->\n<!--X-From-R13: \"Oqevna Rheyrfgre\" <nqe vnaNqheyrfgre.pbz> -->\n<!--X-Date: 11 Aug 2003 14:20:34 -0000 -"..., subject_len=31633, replace_val=0x82d58c4, is_callable_replace=0, result_len=0xbfffd00c, limit=-1) at /opt/php/src/php/ext/pcre/php_pcre.c:867 #21814 0x080e1964 in php_replace_in_subject (regex=0x82d5d14, replace=0x82d58c4, subject=0x82cab68, result_len=0xbfffd00c, limit=-1, is_callable_replace=0 '\0') at /opt/php/src/php/ext/pcre/php_pcre.c:1078 #21815 0x080e2087 in preg_replace_impl (ht=3, return_value=0x82d643c, this_ptr=0x0, return_value_used=1, is_callable_replace=0 '\0') at /opt/php/src/php/ext/pcre/php_pcre.c:1170 #21816 0x080e20dc in zif_preg_replace (ht=3, return_value=0x82d643c, this_ptr=0x0, return_value_used=1) at /opt/php/src/php/ext/pcre/php_pcre.c:1181 #21817 0x081c6333 in execute (op_array=0x82d57e8) at /opt/php/src/php/Zend/zend_execute.c:1640 #21818 0x081c6531 in execute (op_array=0x82d0264) at /opt/php/src/php/Zend/zend_execute.c:1684 #21819 0x081b53e9 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /opt/php/src/php/Zend/zend.c:891 #21820 0x08181774 in php_execute_script (primary_file=0xbffff630) at /opt/php/src/php/main/main.c:1735 #21821 0x081d646b in main (argc=2, argv=0xbffff6b4) at /opt/php/src/php/sapi/cli/php_cli.c:822 #21817 0x081c6333 in execute (op_array=0x82d57e8) at /opt/php/src/php/Zend/zend_execute.c:1640