#39951 [NEW]: PCRE Failed for Long Matches (Less Than MATCH_LIMIT)

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #39951 [NEW]: PCRE Failed for Long Matches (Less Than MATCH_LIMIT)

    From: imacat at mail dot imacat dot idv dot tw
    Operating system: Linux 2.6.16.29
    PHP version: 5.2.0
    PHP Bug Type: PCRE related
    Bug description: PCRE Failed for Long Matches (Less Than MATCH_LIMIT)

    Description:
    ------------
    Hi. This is imacat from Taiwan. I experienced PCRE failure after
    long matches. It doesn't seems to pass the 50000 match limit, UTF-8 or
    not. However, looking into the included PCRE library directory I saw no
    such limit anywhere. In config0.m4 the setting is
    -DMATCH_LIMIT=10000000. In pcrelib/README it states that the default of
    --with-match-limit is 500000. In php.ini I saw
    pcre.backtrack_limit=100000. Whatever I saw are far less than the 50000
    match limit.

    This is hard to me since I have several articles to be parsed that's
    of size over 50000 bytes/characters.

    Reproduce code:
    ---------------
    #! /usr/bin/php
    <?php
    echo "=== Test #01 Non-UTF-8\n";
    $a = str_repeat("a", 49997);
    echo "1. \"a\" repeated 49997 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    $a = str_repeat("a", 49998);
    echo "2. \"a\" repeated 49998 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    echo "=== Test #02 UTF-8\n";
    $a = str_repeat("\xE4\xB8\x80", 49997);
    echo "1. \"\\xE4\\xB8\\x80\" repeated 49997 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    $a = str_repeat("\xE4\xB8\x80", 49998);
    echo "2. \"\\xE4\\xB8\\x80\" repeated 49998 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    ?>


    Expected result:
    ----------------
    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 0
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 0


    Actual result:
    --------------
    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 1
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 1


    --
    Edit bug report at [url]http://bugs.php.net/?id=39951&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=39951&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=39951&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=39951&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=39951&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=39951&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=39951&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=39951&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=39951&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=39951&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=39951&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=39951&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=39951&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=39951&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=39951&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=39951&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=39951&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=39951&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=39951&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=39951&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=39951&r=mysqlcfg[/url]
    imacat at mail dot imacat dot idv dot tw Guest

  2. Similar Questions and Discussions

    1. #25754 [NEW]: preg_replace and preg_replace_callback are crash on long matches
      From: ilya at lebedev dot net Operating system: Win32 PHP version: 4CVS-2003-10-04 (stable) PHP Bug Type: Reproducible crash...
    2. #39951 [Opn]: PCRE Failed for Long Matches (Less Than MATCH_LIMIT)
      ID: 39951 User updated by: imacat at mail dot imacat dot idv dot tw Reported By: imacat at mail dot imacat dot idv dot tw...
    3. Error 403 Failed to read heders Error for long-runningCFMAIL and CFINDEX command
      I have two different pages with long-running scripts on which I am recieving the following error: Error - 403 Failed to read headers to server:...
    4. #26295 [Opn->Bgs]: Change from PCRE Library 3.9 to PCRE library 4.3 has resulted in broken code.
      ID: 26295 Updated by: sniper@php.net Reported By: mnbob70 at earthlink dot net -Status: Open +Status: ...
    5. #26295 [NEW]: Change from PCRE Library 3.9 to PCRE library 4.3 has resulted in broken code.
      From: mnbob70 at earthlink dot net Operating system: Linux lion.phpwebhosting.com 2.4 PHP version: 4.3.4 PHP Bug Type: PCRE...
  3. #2

    Default #39951 [Opn->Bgs]: PCRE Failed for Long Matches (Less Than MATCH_LIMIT)

    ID: 39951
    Updated by: [email]tony2001@php.net[/email]
    Reported By: imacat at mail dot imacat dot idv dot tw
    -Status: Open
    +Status: Bogus
    Bug Type: PCRE related
    Operating System: Linux 2.6.16.29
    PHP Version: 5.2.0
    New Comment:

    [url]http://php.net/pcre[/url]

    Table 1. PCRE Configuration OptionsName Default Changeable Changelog
    pcre.backtrack_limit 100000 PHP_INI_ALL Available since PHP 5.2.0.
    pcre.recursion_limit 100000 PHP_INI_ALL Available since PHP 5.2.0.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-26 07:24:08] imacat at mail dot imacat dot idv dot tw

    I was wrong. ^^; sorry. The Expected Result is:

    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 1
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 1

    And the Actual Result is:

    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 0
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 0

    ------------------------------------------------------------------------

    [2006-12-26 07:20:13] imacat at mail dot imacat dot idv dot tw

    Description:
    ------------
    Hi. This is imacat from Taiwan. I experienced PCRE failure after
    long matches. It doesn't seems to pass the 50000 match limit, UTF-8 or
    not. However, looking into the included PCRE library directory I saw no
    such limit anywhere. In config0.m4 the setting is
    -DMATCH_LIMIT=10000000. In pcrelib/README it states that the default
    of --with-match-limit is 500000. In php.ini I saw
    pcre.backtrack_limit=100000. Whatever I saw are far less than the
    50000 match limit.

    This is hard to me since I have several articles to be parsed
    that's of size over 50000 bytes/characters.

    Reproduce code:
    ---------------
    #! /usr/bin/php
    <?php
    echo "=== Test #01 Non-UTF-8\n";
    $a = str_repeat("a", 49997);
    echo "1. \"a\" repeated 49997 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    $a = str_repeat("a", 49998);
    echo "2. \"a\" repeated 49998 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    echo "=== Test #02 UTF-8\n";
    $a = str_repeat("\xE4\xB8\x80", 49997);
    echo "1. \"\\xE4\\xB8\\x80\" repeated 49997 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    $a = str_repeat("\xE4\xB8\x80", 49998);
    echo "2. \"\\xE4\\xB8\\x80\" repeated 49998 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    ?>


    Expected result:
    ----------------
    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 0
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 0


    Actual result:
    --------------
    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 1
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 1



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39951&edit=1[/url]
    tony2001@php.net Guest

  4. #3

    Default #39951 [Bgs->Csd]: PCRE Failed for Long Matches (Less Than MATCH_LIMIT)

    ID: 39951
    User updated by: imacat at mail dot imacat dot idv dot tw
    Reported By: imacat at mail dot imacat dot idv dot tw
    -Status: Bogus
    +Status: Closed
    Bug Type: PCRE related
    Operating System: Linux 2.6.16.29
    PHP Version: 5.2.0
    New Comment:

    Well.... This must be some kind of blind spot. I spent a lot of time
    finding out the configuration setting, but have never thought of
    altering it.

    It seems to solve the problem. I'm terribly sorry for the bothering.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-26 09:48:59] [email]tony2001@php.net[/email]

    [url]http://php.net/pcre[/url]

    Table 1. PCRE Configuration OptionsName Default Changeable Changelog
    pcre.backtrack_limit 100000 PHP_INI_ALL Available since PHP 5.2.0.
    pcre.recursion_limit 100000 PHP_INI_ALL Available since PHP 5.2.0.

    ------------------------------------------------------------------------

    [2006-12-26 07:24:08] imacat at mail dot imacat dot idv dot tw

    I was wrong. ^^; sorry. The Expected Result is:

    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 1
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 1

    And the Actual Result is:

    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 0
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 0

    ------------------------------------------------------------------------

    [2006-12-26 07:20:13] imacat at mail dot imacat dot idv dot tw

    Description:
    ------------
    Hi. This is imacat from Taiwan. I experienced PCRE failure after
    long matches. It doesn't seems to pass the 50000 match limit, UTF-8 or
    not. However, looking into the included PCRE library directory I saw no
    such limit anywhere. In config0.m4 the setting is
    -DMATCH_LIMIT=10000000. In pcrelib/README it states that the default
    of --with-match-limit is 500000. In php.ini I saw
    pcre.backtrack_limit=100000. Whatever I saw are far less than the
    50000 match limit.

    This is hard to me since I have several articles to be parsed
    that's of size over 50000 bytes/characters.

    Reproduce code:
    ---------------
    #! /usr/bin/php
    <?php
    echo "=== Test #01 Non-UTF-8\n";
    $a = str_repeat("a", 49997);
    echo "1. \"a\" repeated 49997 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    $a = str_repeat("a", 49998);
    echo "2. \"a\" repeated 49998 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    echo "=== Test #02 UTF-8\n";
    $a = str_repeat("\xE4\xB8\x80", 49997);
    echo "1. \"\\xE4\\xB8\\x80\" repeated 49997 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    $a = str_repeat("\xE4\xB8\x80", 49998);
    echo "2. \"\\xE4\\xB8\\x80\" repeated 49998 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    ?>


    Expected result:
    ----------------
    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 0
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 0


    Actual result:
    --------------
    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 1
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 1



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39951&edit=1[/url]
    imacat at mail dot imacat dot idv dot tw Guest

  5. #4

    Default #39951 [Csd->Bgs]: PCRE Failed for Long Matches (Less Than MATCH_LIMIT)

    ID: 39951
    Updated by: [email]tony2001@php.net[/email]
    Reported By: imacat at mail dot imacat dot idv dot tw
    -Status: Closed
    +Status: Bogus
    Bug Type: PCRE related
    Operating System: Linux 2.6.16.29
    PHP Version: 5.2.0


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-26 15:06:24] imacat at mail dot imacat dot idv dot tw

    Well.... This must be some kind of blind spot. I spent a lot of time
    finding out the configuration setting, but have never thought of
    altering it.

    It seems to solve the problem. I'm terribly sorry for the bothering.

    ------------------------------------------------------------------------

    [2006-12-26 09:48:59] [email]tony2001@php.net[/email]

    [url]http://php.net/pcre[/url]

    Table 1. PCRE Configuration OptionsName Default Changeable Changelog
    pcre.backtrack_limit 100000 PHP_INI_ALL Available since PHP 5.2.0.
    pcre.recursion_limit 100000 PHP_INI_ALL Available since PHP 5.2.0.

    ------------------------------------------------------------------------

    [2006-12-26 07:24:08] imacat at mail dot imacat dot idv dot tw

    I was wrong. ^^; sorry. The Expected Result is:

    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 1
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 1

    And the Actual Result is:

    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 0
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 0

    ------------------------------------------------------------------------

    [2006-12-26 07:20:13] imacat at mail dot imacat dot idv dot tw

    Description:
    ------------
    Hi. This is imacat from Taiwan. I experienced PCRE failure after
    long matches. It doesn't seems to pass the 50000 match limit, UTF-8 or
    not. However, looking into the included PCRE library directory I saw no
    such limit anywhere. In config0.m4 the setting is
    -DMATCH_LIMIT=10000000. In pcrelib/README it states that the default
    of --with-match-limit is 500000. In php.ini I saw
    pcre.backtrack_limit=100000. Whatever I saw are far less than the
    50000 match limit.

    This is hard to me since I have several articles to be parsed
    that's of size over 50000 bytes/characters.

    Reproduce code:
    ---------------
    #! /usr/bin/php
    <?php
    echo "=== Test #01 Non-UTF-8\n";
    $a = str_repeat("a", 49997);
    echo "1. \"a\" repeated 49997 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    $a = str_repeat("a", 49998);
    echo "2. \"a\" repeated 49998 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    echo "=== Test #02 UTF-8\n";
    $a = str_repeat("\xE4\xB8\x80", 49997);
    echo "1. \"\\xE4\\xB8\\x80\" repeated 49997 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    $a = str_repeat("\xE4\xB8\x80", 49998);
    echo "2. \"\\xE4\\xB8\\x80\" repeated 49998 times\n";
    printf(" strlen(): %6d, preg_match(): %d\n",
    strlen($a), preg_match("/^(.*?)\s*$/us", $a));
    ?>


    Expected result:
    ----------------
    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 0
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 0


    Actual result:
    --------------
    === Test #01 Non-UTF-8
    1. "a" repeated 49997 times
    strlen(): 49997, preg_match(): 1
    2. "a" repeated 49998 times
    strlen(): 49998, preg_match(): 1
    === Test #02 UTF-8
    1. "\xE4\xB8\x80" repeated 49997 times
    strlen(): 149991, preg_match(): 1
    2. "\xE4\xB8\x80" repeated 49998 times
    strlen(): 149994, preg_match(): 1



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39951&edit=1[/url]
    tony2001@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139