Ignore:
Timestamp:
Feb 5, 2017, 11:26:50 AM (8 years ago)
Author:
[email protected]
Message:

The VMInspector should use an RAII Locker.
https://bugs.webkit.org/show_bug.cgi?id=167854

Reviewed by Saam Barati.

Previously, VMInspector::lock() was returning an expected LockToken, and there's
no way to unlock it when we're done with it. This was not a problem before
because the VMInspector had only one client, the SigillCrashAnalyzer, that
expected the process to crash due to a SIGILL shortly thereafter.

However, the VMInspector is useful as a debugging tool that we can apply in other
debugging tasks. Fixing VMInspector::lock() to return an RAII locker will enable
other use cases. Plus it's just bad form to be able to lock something and never
be able to unlock it.

  • tools/SigillCrashAnalyzer.cpp:

(JSC::SigillCrashAnalyzer::analyze):

  • tools/VMInspector.cpp:
  • tools/VMInspector.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp

    r211603 r211684  
    242242        // Use a timeout period of 2 seconds. The client is about to crash, and we don't
    243243        // want to turn the crash into a hang by re-trying the lock for too long.
    244         auto expectedLockToken = inspector.lock(Seconds(2));
    245         if (!expectedLockToken) {
    246             ASSERT(expectedLockToken.error() == VMInspector::Error::TimedOut);
     244        auto expectedLocker = inspector.lock(Seconds(2));
     245        if (!expectedLocker) {
     246            ASSERT(expectedLocker.error() == VMInspector::Error::TimedOut);
    247247            log("ERROR: Unable to analyze SIGILL. Timed out while waiting to iterate VMs.");
    248248            return;
    249249        }
    250         auto lockToken = expectedLockToken.value();
     250        auto& locker = expectedLocker.value();
    251251
    252252        void* pc = context.machinePC;
    253         auto isInJITMemory = inspector.isValidExecutableMemory(lockToken, pc);
     253        auto isInJITMemory = inspector.isValidExecutableMemory(locker, pc);
    254254        if (!isInJITMemory) {
    255255            log("ERROR: Timed out: not able to determine if pc %p is in valid JIT executable memory", pc);
     
    275275#endif
    276276
    277         auto expectedCodeBlock = inspector.codeBlockForMachinePC(lockToken, pc);
     277        auto expectedCodeBlock = inspector.codeBlockForMachinePC(locker, pc);
    278278        if (!expectedCodeBlock) {
    279279            if (expectedCodeBlock.error() == VMInspector::Error::TimedOut)
Note: See TracChangeset for help on using the changeset viewer.