⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244023 in webkit


Ignore:
Timestamp:
Apr 8, 2019, 10:09:21 AM (7 years ago)
Author:
bshafiei@apple.com
Message:

Cherry-pick r243839. rdar://problem/49589308

REGRESSION (r243642): com.apple.JavaScriptCore crash in JSC::RegExpObject::execInline
https://bugs.webkit.org/show_bug.cgi?id=196477

Reviewed by Keith Miller.

Source/JavaScriptCore:

The problem here is that when we advance the index by 2 for a character class that only
has non-BMP characters, we might go past the end of the string. This can happen for
greedy counted character classes that are part of a alternative where there is one
character to match after the greedy non-BMP character class.

The "do we have string left to match" check at the top of the JIT loop for the counted
character class checks to see if index is not equal to the string length. For non-BMP
character classes, we need to check to see if there are at least 2 characters left.
Therefore we now temporarily add 1 to the current index before comparing. This checks
to see if there are iat least 2 characters left to match, instead of 1.

  • yarr/YarrJIT.cpp: (JSC::Yarr::YarrGenerator::generateCharacterClassGreedy): (JSC::Yarr::YarrGenerator::backtrackCharacterClassNonGreedy):

LayoutTests:

Updated the test with a couple more test cases to test a few variants of this bug.
Also added a couple of non-greedy counted non-BMP character class tests that don't have
the bug just to be sure.

  • js/regexp-unicode-expected.txt:
  • js/script-tests/regexp-unicode.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243839 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
tags/Safari-608.1.15
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • tags/Safari-608.1.15/LayoutTests/ChangeLog

    r243949 r244023  
     12019-04-08  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Cherry-pick r243839. rdar://problem/49589308
     4
     5    REGRESSION (r243642): com.apple.JavaScriptCore crash in JSC::RegExpObject::execInline
     6    https://bugs.webkit.org/show_bug.cgi?id=196477
     7   
     8    Reviewed by Keith Miller.
     9   
     10    Source/JavaScriptCore:
     11   
     12    The problem here is that when we advance the index by 2 for a character class that only
     13    has non-BMP characters, we might go past the end of the string.  This can happen for
     14    greedy counted character classes that are part of a alternative where there is one
     15    character to match after the greedy non-BMP character class.
     16   
     17    The "do we have string left to match" check at the top of the JIT loop for the counted
     18    character class checks to see if index is not equal to the string length.  For non-BMP
     19    character classes, we need to check to see if there are at least 2 characters left.
     20    Therefore we now temporarily add 1 to the current index before comparing.  This checks
     21    to see if there are iat least 2 characters left to match, instead of 1.
     22   
     23    * yarr/YarrJIT.cpp:
     24    (JSC::Yarr::YarrGenerator::generateCharacterClassGreedy):
     25    (JSC::Yarr::YarrGenerator::backtrackCharacterClassNonGreedy):
     26   
     27    LayoutTests:
     28   
     29    Updated the test with a couple more test cases to test a few variants of this bug.
     30    Also added a couple of non-greedy counted non-BMP character class tests that don't have
     31    the bug just to be sure.
     32   
     33    * js/regexp-unicode-expected.txt:
     34    * js/script-tests/regexp-unicode.js:
     35   
     36   
     37    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243839 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     38
     39    2019-04-03  Michael Saboff  <msaboff@apple.com>
     40
     41            REGRESSION (r243642): com.apple.JavaScriptCore crash in JSC::RegExpObject::execInline
     42            https://bugs.webkit.org/show_bug.cgi?id=196477
     43
     44            Reviewed by Keith Miller.
     45
     46            Updated the test with a couple more test cases to test a few variants of this bug.
     47            Also added a couple of non-greedy counted non-BMP character class tests that don't have
     48            the bug just to be sure.
     49
     50            * js/regexp-unicode-expected.txt:
     51            * js/script-tests/regexp-unicode.js:
     52
    1532019-04-05  Kocsen Chung  <kocsen_chung@apple.com>
    254
  • tags/Safari-608.1.15/LayoutTests/js/regexp-unicode-expected.txt

    r243949 r244023  
    149149PASS "𐌑𐌐𐌑".match(/[𐌁𐌑]+a|[𐌐𐌑]+./iu)[0] is "𐌑𐌐𐌑"
    150150PASS "𐌑𐌐𐌑".match(/[𐌁𐌑]+?a|[𐌐𐌑]+?./iu)[0] is "𐌑𐌐"
     151PASS "𐌑𐌐𐌑".match(/[𐌁𐌑]+?a$|[𐌐𐌑]+?.$/iu)[0] is "𐌑𐌐𐌑"
     152PASS "𐌑𐌐𐌑".match(/[𐌁𐌑x]+a|[𐌐𐌑x]+./iu)[0] is "𐌑𐌐𐌑"
     153PASS "𐌑𐌐𐌑".match(/[𐌁𐌑x]+?a|[𐌐𐌑x]+?./iu)[0] is "𐌑𐌐"
    151154PASS "C83|НАЧАТЬ".match(re8)[0] is "C83|НАЧАТЬ"
    152155PASS "This.Is.16.Chars|НАЧАТЬ".match(re8)[0] is "This.Is.16.Chars|НАЧАТЬ"
  • tags/Safari-608.1.15/LayoutTests/js/script-tests/regexp-unicode.js

    r243949 r244023  
    206206shouldBe('"\u{10311}\u{10310}\u{10311}".match(/[\u{10301}\u{10311}]+a|[\u{10310}\u{10311}]+./iu)[0]', '"\u{10311}\u{10310}\u{10311}"');
    207207shouldBe('"\u{10311}\u{10310}\u{10311}".match(/[\u{10301}\u{10311}]+?a|[\u{10310}\u{10311}]+?./iu)[0]', '"\u{10311}\u{10310}"');
     208shouldBe('"\u{10311}\u{10310}\u{10311}".match(/[\u{10301}\u{10311}]+?a$|[\u{10310}\u{10311}]+?.$/iu)[0]', '"\u{10311}\u{10310}\u{10311}"');
     209shouldBe('"\u{10311}\u{10310}\u{10311}".match(/[\u{10301}\u{10311}x]+a|[\u{10310}\u{10311}x]+./iu)[0]', '"\u{10311}\u{10310}\u{10311}"');
     210shouldBe('"\u{10311}\u{10310}\u{10311}".match(/[\u{10301}\u{10311}x]+?a|[\u{10310}\u{10311}x]+?./iu)[0]', '"\u{10311}\u{10310}"');
    208211
    209212var re8 = new  RegExp("^([0-9a-z\.]{3,16})\\|\u{041d}\u{0410}\u{0427}\u{0410}\u{0422}\u{042c}", "ui");
  • tags/Safari-608.1.15/Source/JavaScriptCore/ChangeLog

    r244022 r244023  
     12019-04-08  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Cherry-pick r243839. rdar://problem/49589308
     4
     5    REGRESSION (r243642): com.apple.JavaScriptCore crash in JSC::RegExpObject::execInline
     6    https://bugs.webkit.org/show_bug.cgi?id=196477
     7   
     8    Reviewed by Keith Miller.
     9   
     10    Source/JavaScriptCore:
     11   
     12    The problem here is that when we advance the index by 2 for a character class that only
     13    has non-BMP characters, we might go past the end of the string.  This can happen for
     14    greedy counted character classes that are part of a alternative where there is one
     15    character to match after the greedy non-BMP character class.
     16   
     17    The "do we have string left to match" check at the top of the JIT loop for the counted
     18    character class checks to see if index is not equal to the string length.  For non-BMP
     19    character classes, we need to check to see if there are at least 2 characters left.
     20    Therefore we now temporarily add 1 to the current index before comparing.  This checks
     21    to see if there are iat least 2 characters left to match, instead of 1.
     22   
     23    * yarr/YarrJIT.cpp:
     24    (JSC::Yarr::YarrGenerator::generateCharacterClassGreedy):
     25    (JSC::Yarr::YarrGenerator::backtrackCharacterClassNonGreedy):
     26   
     27    LayoutTests:
     28   
     29    Updated the test with a couple more test cases to test a few variants of this bug.
     30    Also added a couple of non-greedy counted non-BMP character class tests that don't have
     31    the bug just to be sure.
     32   
     33    * js/regexp-unicode-expected.txt:
     34    * js/script-tests/regexp-unicode.js:
     35   
     36   
     37    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243839 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     38
     39    2019-04-03  Michael Saboff  <msaboff@apple.com>
     40
     41            REGRESSION (r243642): com.apple.JavaScriptCore crash in JSC::RegExpObject::execInline
     42            https://bugs.webkit.org/show_bug.cgi?id=196477
     43
     44            Reviewed by Keith Miller.
     45
     46            The problem here is that when we advance the index by 2 for a character class that only
     47            has non-BMP characters, we might go past the end of the string.  This can happen for
     48            greedy counted character classes that are part of a alternative where there is one
     49            character to match after the greedy non-BMP character class.
     50
     51            The "do we have string left to match" check at the top of the JIT loop for the counted
     52            character class checks to see if index is not equal to the string length.  For non-BMP
     53            character classes, we need to check to see if there are at least 2 characters left.
     54            Therefore we now temporarily add 1 to the current index before comparing.  This checks
     55            to see if there are iat least 2 characters left to match, instead of 1.
     56
     57            * yarr/YarrJIT.cpp:
     58            (JSC::Yarr::YarrGenerator::generateCharacterClassGreedy):
     59            (JSC::Yarr::YarrGenerator::backtrackCharacterClassNonGreedy):
     60
    1612019-04-08  Babak Shafiei  <bshafiei@apple.com>
    262
  • tags/Safari-608.1.15/Source/JavaScriptCore/yarr/YarrJIT.cpp

    r244022 r244023  
    18501850        JumpList failures;
    18511851        Label loop(this);
    1852         failures.append(atEndOfInput());
     1852#ifdef JIT_UNICODE_EXPRESSIONS
     1853        if (term->characterClass->hasOneCharacterSize() && !term->invert() && term->characterClass->hasNonBMPCharacters()) {
     1854            move(TrustedImm32(1), character);
     1855            failures.append(checkNotEnoughInput(character));
     1856        } else
     1857#endif
     1858            failures.append(atEndOfInput());
    18531859
    18541860        if (term->invert()) {
     
    19571963        m_backtrackingState.link(this);
    19581964
     1965#ifdef JIT_UNICODE_EXPRESSIONS
    19591966        if (m_decodeSurrogatePairs) {
    19601967            if (!term->characterClass->hasOneCharacterSize() || term->invert())
     
    19621969            loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex(), countRegister);
    19631970        }
     1971#endif
    19641972
    19651973        nonGreedyFailures.append(atEndOfInput());
Note: See TracChangeset for help on using the changeset viewer.