Changeset 167396 in webkit


Ignore:
Timestamp:
Apr 16, 2014 4:07:49 PM (10 years ago)
Author:
mark.lam@apple.com
Message:

Crash in CodeBlock::setOptimizationThresholdBasedOnCompilationResult() when the debugger activates.
<https://webkit.org/b/131747>

Reviewed by Filip Pizlo.

When the debugger is about to activate (e.g. enter stepping mode), it first
waits for all DFG compilations to complete. However, when the DFG completes,
if compilation is successful, it will install a new DFG codeBlock. The
CodeBlock installation process is required to register codeBlocks with the
debugger. Debugger::registerCodeBlock() will eventually call
CodeBlock::setSteppingMode() which may jettison the DFG codeBlock that we're
trying to install. Thereafter, chaos ensues.

This jettison'ing only happens because the debugger currently set its
m_steppingMode flag before waiting for compilation to complete. The fix is
simply to set that flag only after compilation is complete.

  • debugger/Debugger.cpp:

(JSC::Debugger::setSteppingMode):
(JSC::Debugger::registerCodeBlock):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r167394 r167396  
     12014-04-16  Mark Lam  <mark.lam@apple.com>
     2
     3        Crash in CodeBlock::setOptimizationThresholdBasedOnCompilationResult() when the debugger activates.
     4        <https://webkit.org/b/131747>
     5
     6        Reviewed by Filip Pizlo.
     7
     8        When the debugger is about to activate (e.g. enter stepping mode), it first
     9        waits for all DFG compilations to complete.  However, when the DFG completes,
     10        if compilation is successful, it will install a new DFG codeBlock.  The
     11        CodeBlock installation process is required to register codeBlocks with the
     12        debugger.  Debugger::registerCodeBlock() will eventually call
     13        CodeBlock::setSteppingMode() which may jettison the DFG codeBlock that we're
     14        trying to install.  Thereafter, chaos ensues.
     15
     16        This jettison'ing only happens because the debugger currently set its
     17        m_steppingMode flag before waiting for compilation to complete.  The fix is
     18        simply to set that flag only after compilation is complete.
     19
     20        * debugger/Debugger.cpp:
     21        (JSC::Debugger::setSteppingMode):
     22        (JSC::Debugger::registerCodeBlock):
     23
    1242014-04-16  Filip Pizlo  <fpizlo@apple.com>
    225
  • trunk/Source/JavaScriptCore/debugger/Debugger.cpp

    r165005 r167396  
    233233void Debugger::setSteppingMode(SteppingMode mode)
    234234{
    235     if (mode == m_steppingMode)
    236         return;
     235    if (mode == m_steppingMode || !m_vm)
     236        return;
     237
     238    m_vm->waitForCompilationsToComplete();
     239
    237240    m_steppingMode = mode;
    238 
    239     if (!m_vm)
    240         return;
    241241    SetSteppingModeFunctor functor(this, mode);
    242     forEachCodeBlock(functor);
     242    m_vm->heap.forEachCodeBlock(functor);
    243243}
    244244
    245245void Debugger::registerCodeBlock(CodeBlock* codeBlock)
    246246{
     247    // FIXME: We should never have to jettison a code block (due to pending breakpoints
     248    // or stepping mode) that is being registered. operationOptimize() should have
     249    // prevented the optimizing of such code blocks in the first place. Find a way to
     250    // express this with greater clarity in the code. See <https://webkit.org/b131771>.
    247251    applyBreakpoints(codeBlock);
    248252    if (isStepping())
Note: See TracChangeset for help on using the changeset viewer.