Changeset 221111 in webkit


Ignore:
Timestamp:
Aug 23, 2017 3:24:30 PM (7 years ago)
Author:
msaboff@apple.com
Message:

REGRESSION (r221052): DumpRenderTree crashed in com.apple.JavaScriptCore: JSC::Yarr::YarrCodeBlock::execute + 137
https://bugs.webkit.org/show_bug.cgi?id=175903

Reviewed by Saam Barati.

Source/JavaScriptCore:

In generateCharacterClassGreedy we were incrementing the "count" register before checking
for the end of the input string. The at-end-of-input check is the final check before
knowing that the current character matched. In this case, the end of input check
indicates that we ran out of prechecked characters and therefore should fail the match of
the current character. The backtracking code uses the value in the "count" register as
the number of character that successfully matched, which shouldn't include the current
character. Therefore we need to move the incrementing of "count" to after the
at end of input check.

Through code inspection of the expectations of other backtracking code, I determined that
the non greedy character class matching code had a similar issue. I fixed that as well
and added a new test case.

  • yarr/YarrJIT.cpp:

(JSC::Yarr::YarrGenerator::generateCharacterClassGreedy):
(JSC::Yarr::YarrGenerator::backtrackCharacterClassNonGreedy):

LayoutTests:

New regression test case.

  • js/regexp-unicode-expected.txt:
  • js/script-tests/regexp-unicode.js:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r221101 r221111  
     12017-08-23  Michael Saboff  <msaboff@apple.com>
     2
     3        REGRESSION (r221052): DumpRenderTree crashed in com.apple.JavaScriptCore: JSC::Yarr::YarrCodeBlock::execute + 137
     4        https://bugs.webkit.org/show_bug.cgi?id=175903
     5
     6        Reviewed by Saam Barati.
     7
     8        New regression test case.
     9
     10        * js/regexp-unicode-expected.txt:
     11        * js/script-tests/regexp-unicode.js:
     12
    1132017-08-23  Matt Lewis  <jlewis3@apple.com>
    214
  • trunk/LayoutTests/js/regexp-unicode-expected.txt

    r221052 r221111  
    120120PASS "12X3𐐀4".match(/\d{0,1}/ug) is ["1", "2", "", "3", "", "4", ""]
    121121PASS "𐐂𐐅𐐅𐐂𐐅𐐅𐐅".match(/𐐅{3}/u)[0] is "𐐅𐐅𐐅"
     122PASS "a𐐐𐐐b".match(/a(𐐐*?)bc|a(𐐐*?)b/ui)[0] is "a𐐐𐐐b"
    122123PASS match3[0] is "a𐐐𐐐b"
    123124PASS match3[1] is undefined.
  • trunk/LayoutTests/js/script-tests/regexp-unicode.js

    r221052 r221111  
    158158shouldBe('"12X3\u{10400}4".match(/\\d{0,1}/ug)', '["1", "2", "", "3", "", "4", ""]');
    159159shouldBe('"\u{10402}\u{10405}\u{10405}\u{10402}\u{10405}\u{10405}\u{10405}".match(/\u{10405}{3}/u)[0]', '"\u{10405}\u{10405}\u{10405}"');
     160shouldBe('"a\u{10410}\u{10410}b".match(/a(\u{10410}*?)bc|a(\u{10410}*?)b/ui)[0]', '"a\u{10410}\u{10410}b"');
    160161
    161162var re3 = new RegExp("(a\u{10410}*bc)|(a\u{10410}*b)", "u");
  • trunk/Source/JavaScriptCore/ChangeLog

    r221110 r221111  
     12017-08-23  Michael Saboff  <msaboff@apple.com>
     2
     3        REGRESSION (r221052): DumpRenderTree crashed in com.apple.JavaScriptCore: JSC::Yarr::YarrCodeBlock::execute + 137
     4        https://bugs.webkit.org/show_bug.cgi?id=175903
     5
     6        Reviewed by Saam Barati.
     7
     8        In generateCharacterClassGreedy we were incrementing the "count" register before checking
     9        for the end of the input string.  The at-end-of-input check is the final check before
     10        knowing that the current character matched.  In this case, the end of input check
     11        indicates that we ran out of prechecked characters and therefore should fail the match of
     12        the current character.  The backtracking code uses the value in the "count" register as
     13        the number of character that successfully matched, which shouldn't include the current
     14        character.  Therefore we need to move the incrementing of "count" to after the
     15        at end of input check.
     16
     17        Through code inspection of the expectations of other backtracking code, I determined that
     18        the non greedy character class matching code had a similar issue.  I fixed that as well
     19        and added a new test case.
     20
     21        * yarr/YarrJIT.cpp:
     22        (JSC::Yarr::YarrGenerator::generateCharacterClassGreedy):
     23        (JSC::Yarr::YarrGenerator::backtrackCharacterClassNonGreedy):
     24
    1252017-08-23  Yusuke Suzuki  <utatane.tea@gmail.com>
    226
  • trunk/Source/JavaScriptCore/yarr/YarrJIT.cpp

    r221052 r221111  
    12691269        }
    12701270
    1271         add32(TrustedImm32(1), countRegister);
    12721271        add32(TrustedImm32(1), index);
    12731272#ifdef JIT_UNICODE_EXPRESSIONS
     
    12791278        }
    12801279#endif
     1280        add32(TrustedImm32(1), countRegister);
    12811281
    12821282        if (term->quantityMaxCount != quantifyInfinite) {
     
    13751375        }
    13761376
    1377         add32(TrustedImm32(1), countRegister);
    13781377        add32(TrustedImm32(1), index);
    13791378#ifdef JIT_UNICODE_EXPRESSIONS
    13801379        if (m_decodeSurrogatePairs) {
     1380            nonGreedyFailures.append(atEndOfInput());
    13811381            Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
    13821382            add32(TrustedImm32(1), index);
     
    13841384        }
    13851385#endif
     1386        add32(TrustedImm32(1), countRegister);
    13861387
    13871388        jump(op.m_reentry);
Note: See TracChangeset for help on using the changeset viewer.