#372 ConvertOldMarkup() crashes PHP from preg_match()

PHP_error
closed
5
2012-10-11
2004-08-21
Anonymous
No

I just upgraded from 1.2 stable to 1.3.10. PHP now
crashes consistently while PhpWiki tries to do a virgin
DB setup from pgsrc.

Specifically, the file "OldTextFormattingRules" has a
chunk of text that apparently is too long for
preg_match to handle with the complicated pattern begin
used.

You can recreate the problem (on my machine at least)
simply by running this code below on its own, which
crashes the same way (and uses the same pattern):

-- Sample Begin --
$pat = "/\A((?:.|\n)?)(^(?:[ \t]+\S(?:.\s\n[ \t]+\S)|".
"\|(?:.\n\|)|[#*;](?:[*#]|;.?:)|[\s(\d+)\s]|".
"<\?plugin(?:-form)?\b.\?>\s$|!{1,3}[^!]).*$)\n?/m";
$subj = str_repeat("123456789 ", 50);
preg_match($pat, $subj);
-- Sample End --

This maybe is a PCRE bug. See LIMITATIONS section of:
http://www.pcre.org/pcre.txt . Or it could be a
malformed search pattern (as generated in
stdlib.php:ConvertOldMarkup()), but I'm not great at
debugging other people's regexps.

Either way, it's preventing me from using PhpWiki at
all (and took me hours to figure out what was even
crashing), and it would be great if somebody with more
knowledge could dig into this and either fix it or
recommend a workaround to get up and running on 1.3.

My system is Apache2 on Win2k. I upgraded from PHP
4.3.0 to newest 4.3.8, but no difference.

Discussion

  • Reini Urban

    Reini Urban - 2004-10-20

    Logged In: YES
    user_id=13755

    This is apparently fixed in php-4.3.9.
    At least it doesn't crash at your regexp, and doesn't crash
    that often in my testsuite.

    But memory consumption is still high, and the \A anchor
    should really go away.

     
  • Reini Urban

    Reini Urban - 2004-10-20

    Logged In: YES
    user_id=13755

    hmm, unfortunately not really reproducable.

    $ for f in /f/Apache/php-4.3.*/php; do echo -n "$f "; $f
    -nCq pcre-crash.php ; done
    /f/Apache/php-4.3.2/php ok
    /f/Apache/php-4.3.5/php ok
    /f/Apache/php-4.3.7dev/php ok
    /f/Apache/php-4.3.9/php ok
    /f/Apache/php-4.3.9RC2/php ok

    $ cat pcre-crash.php
    <?php
    $pat = "/\A((?:.|\n)?)(^(?:[ \t]+\S(?:.\s\n[ \t]+\S)|".
    "\|(?:.\n\|)|[#*;](?:[*#]|;.?:)|[\s(\d+)\s]|".
    "<\?plugin(?:-form)?\b.\?>\s$|!{1,3}[^!]).*$)\n?/m";
    $subj = str_repeat("123456789 ", 50);
    preg_match($pat, $subj);
    echo "ok\n";
    ?>

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks