Ignore:
Timestamp:
May 19, 2016, 2:02:44 PM (9 years ago)
Author:
[email protected]
Message:

Code that null checks the VM pointer before any use should ref the VM.
https://bugs.webkit.org/show_bug.cgi?id=157864

Reviewed by Filip Pizlo and Keith Miller.

JSLock::willReleaseLock() and HeapTimer::timerDidFire() need to reference the VM
through a RefPtr. Otherwise, there's no guarantee that the VM won't be deleted
after their null checks.

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::vm):
(JSC::CodeBlock::setVM): Deleted.

  • Not used, and suggests that it can be changed during the lifetime of the CodeBlock (which should not be).
  • heap/HeapTimer.cpp:

(JSC::HeapTimer::timerDidFire):

  • runtime/JSLock.cpp:

(JSC::JSLock::willReleaseLock):

  • Store the VM pointer in a RefPtr first, and null check the RefPtr instead of the raw VM pointer. This makes the null check a strong guarantee that the VM pointer is valid while these functions are using it.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/HeapTimer.cpp

    r192773 r201180  
    8181    apiLock->lock();
    8282
    83     VM* vm = apiLock->vm();
    84     // The VM has been destroyed, so we should just give up.
     83    RefPtr<VM> vm = apiLock->vm();
    8584    if (!vm) {
     85        // The VM has been destroyed, so we should just give up.
    8686        apiLock->unlock();
    8787        return;
     
    9999
    100100    {
    101         JSLockHolder locker(vm);
     101        JSLockHolder locker(vm.get());
    102102        heapTimer->doWork();
    103103    }
Note: See TracChangeset for help on using the changeset viewer.