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

Changeset 245939 in webkit


Ignore:
Timestamp:
May 30, 2019, 5:33:42 PM (7 years ago)
Author:
Alan Coon
Message:

Cherry-pick r243237. rdar://problem/51264876

JSC test crash: stress/dont-strength-reduce-regexp-with-compile-error.js.default
https://bugs.webkit.org/show_bug.cgi?id=195906

Reviewed by Mark Lam.

The problem here as that we may successfully parsed a RegExp without running out of stack,
but later run out of stack when trying to JIT compile the same expression.

Added a check for available stack space when we call into one of the parenthesis compilation
functions that recurse. When we don't have enough stack space to recurse, we fail the JIT
compilation and let the interpreter handle the expression.

From code inspection of the YARR interpreter it has the same issue, but I couldn't cause a failure.
Filed a new bug and added a FIXME comment for the Interpreter to have similar checks.
Given that we can reproduce a failure, this is sufficient for now.

This change is covered by the previously added failing test,
JSTests/stress/dont-strength-reduce-regexp-with-compile-error.js.

  • yarr/YarrInterpreter.cpp: (JSC::Yarr::Interpreter::interpret):
  • yarr/YarrJIT.cpp: (JSC::Yarr::YarrGenerator::opCompileParenthesesSubpattern): (JSC::Yarr::YarrGenerator::opCompileParentheticalAssertion): (JSC::Yarr::YarrGenerator::opCompileBody): (JSC::Yarr::dumpCompileFailure):
  • yarr/YarrJIT.h:

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

Location:
branches/safari-607-branch/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-607-branch/Source/JavaScriptCore/ChangeLog

    r245933 r245939  
     12019-05-30  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r243237. rdar://problem/51264876
     4
     5    JSC test crash: stress/dont-strength-reduce-regexp-with-compile-error.js.default
     6    https://bugs.webkit.org/show_bug.cgi?id=195906
     7   
     8    Reviewed by Mark Lam.
     9   
     10    The problem here as that we may successfully parsed a RegExp without running out of stack,
     11    but later run out of stack when trying to JIT compile the same expression.
     12   
     13    Added a check for available stack space when we call into one of the parenthesis compilation
     14    functions that recurse.  When we don't have enough stack space to recurse, we fail the JIT
     15    compilation and let the interpreter handle the expression.
     16   
     17    From code inspection of the YARR interpreter it has the same issue, but I couldn't cause a failure.
     18    Filed a new bug and added a FIXME comment for the Interpreter to have similar checks.
     19    Given that we can reproduce a failure, this is sufficient for now.
     20   
     21    This change is covered by the previously added failing test,
     22    JSTests/stress/dont-strength-reduce-regexp-with-compile-error.js.
     23   
     24    * yarr/YarrInterpreter.cpp:
     25    (JSC::Yarr::Interpreter::interpret):
     26    * yarr/YarrJIT.cpp:
     27    (JSC::Yarr::YarrGenerator::opCompileParenthesesSubpattern):
     28    (JSC::Yarr::YarrGenerator::opCompileParentheticalAssertion):
     29    (JSC::Yarr::YarrGenerator::opCompileBody):
     30    (JSC::Yarr::dumpCompileFailure):
     31    * yarr/YarrJIT.h:
     32   
     33   
     34    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243237 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     35
     36    2019-03-20  Michael Saboff  <msaboff@apple.com>
     37
     38            JSC test crash: stress/dont-strength-reduce-regexp-with-compile-error.js.default
     39            https://bugs.webkit.org/show_bug.cgi?id=195906
     40
     41            Reviewed by Mark Lam.
     42
     43            The problem here as that we may successfully parsed a RegExp without running out of stack,
     44            but later run out of stack when trying to JIT compile the same expression.
     45
     46            Added a check for available stack space when we call into one of the parenthesis compilation
     47            functions that recurse.  When we don't have enough stack space to recurse, we fail the JIT
     48            compilation and let the interpreter handle the expression.
     49
     50            From code inspection of the YARR interpreter it has the same issue, but I couldn't cause a failure.
     51            Filed a new bug and added a FIXME comment for the Interpreter to have similar checks.
     52            Given that we can reproduce a failure, this is sufficient for now.
     53
     54            This change is covered by the previously added failing test,
     55            JSTests/stress/dont-strength-reduce-regexp-with-compile-error.js.
     56
     57            * yarr/YarrInterpreter.cpp:
     58            (JSC::Yarr::Interpreter::interpret):
     59            * yarr/YarrJIT.cpp:
     60            (JSC::Yarr::YarrGenerator::opCompileParenthesesSubpattern):
     61            (JSC::Yarr::YarrGenerator::opCompileParentheticalAssertion):
     62            (JSC::Yarr::YarrGenerator::opCompileBody):
     63            (JSC::Yarr::dumpCompileFailure):
     64            * yarr/YarrJIT.h:
     65
    1662019-05-30  Kocsen Chung  <kocsen_chung@apple.com>
    267
  • branches/safari-607-branch/Source/JavaScriptCore/yarr/YarrInterpreter.cpp

    r234916 r245939  
    16091609    unsigned interpret()
    16101610    {
     1611        // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195970
     1612        // [Yarr Interpreter] The interpreter doesn't have checks for stack overflow due to deep recursion
    16111613        if (!input.isAvailableInput(0))
    16121614            return offsetNoMatch;
  • branches/safari-607-branch/Source/JavaScriptCore/yarr/YarrJIT.cpp

    r245928 r245939  
    33903390        YarrOpCode alternativeEndOpCode = OpSimpleNestedAlternativeEnd;
    33913391
     3392        if (UNLIKELY(!m_vm->isSafeToRecurse())) {
     3393            m_failureReason = JITFailureReason::ParenthesisNestedTooDeep;
     3394            return;
     3395        }
     3396
    33923397        // We can currently only compile quantity 1 subpatterns that are
    33933398        // not copies. We generate a copy in the case of a range quantifier,
     
    34963501    void opCompileParentheticalAssertion(PatternTerm* term)
    34973502    {
     3503        if (UNLIKELY(!m_vm->isSafeToRecurse())) {
     3504            m_failureReason = JITFailureReason::ParenthesisNestedTooDeep;
     3505            return;
     3506        }
     3507
    34983508        size_t parenBegin = m_ops.size();
    34993509        m_ops.append(OpParentheticalAssertionBegin);
     
    35763586    void opCompileBody(PatternDisjunction* disjunction)
    35773587    {
     3588        if (UNLIKELY(!m_vm->isSafeToRecurse())) {
     3589            m_failureReason = JITFailureReason::ParenthesisNestedTooDeep;
     3590            return;
     3591        }
     3592       
    35783593        Vector<std::unique_ptr<PatternAlternative>>& alternatives = disjunction->m_alternatives;
    35793594        size_t currentAlternativeIndex = 0;
     
    42094224        dataLog("Can't JIT a pattern containing fixed count parenthesized subpatterns\n");
    42104225        break;
     4226    case JITFailureReason::ParenthesisNestedTooDeep:
     4227        dataLog("Can't JIT pattern due to parentheses nested too deeply\n");
     4228        break;
    42114229    case JITFailureReason::ExecutableMemoryAllocationFailure:
    42124230        dataLog("Can't JIT because of failure of allocation of executable memory\n");
  • branches/safari-607-branch/Source/JavaScriptCore/yarr/YarrJIT.h

    r245926 r245939  
    5353    ParenthesizedSubpattern,
    5454    FixedCountParenthesizedSubpattern,
     55    ParenthesisNestedTooDeep,
    5556    ExecutableMemoryAllocationFailure,
    5657};
Note: See TracChangeset for help on using the changeset viewer.