Changeset 232215 in webkit


Ignore:
Timestamp:
May 25, 2018 4:45:36 PM (6 years ago)
Author:
mark.lam@apple.com
Message:

MachineContext's instructionPointer() should handle null PCs correctly.
https://bugs.webkit.org/show_bug.cgi?id=186004
<rdar://problem/40570067>

Reviewed by Saam Barati.

instructionPointer() returns a MacroAssemblerCodePtr<CFunctionPtrTag>. However,
MacroAssemblerCodePtr's constructor does not accept a null pointer value and will
assert accordingly with a debug ASSERT. This is inconsequential for release
builds, but to avoid this assertion failure, we should check for a null PC and
return MacroAssemblerCodePtr<CFunctionPtrTag>(nullptr) instead (which uses the
MacroAssemblerCodePtr(std::nullptr_t) version of the constructor instead).

Alternatively, we can change all of MacroAssemblerCodePtr's constructors to check
for null pointers, but I rather not do that yet. In general,
MacroAssemblerCodePtrs are constructed with non-null pointers, and I prefer to
leave it that way for now.

Note: this assertion failure only manifests when we have signal traps enabled,
and encounter a null pointer deref.

  • runtime/MachineContext.h:

(JSC::MachineContext::instructionPointer):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r232211 r232215  
     12018-05-25  Mark Lam  <mark.lam@apple.com>
     2
     3        MachineContext's instructionPointer() should handle null PCs correctly.
     4        https://bugs.webkit.org/show_bug.cgi?id=186004
     5        <rdar://problem/40570067>
     6
     7        Reviewed by Saam Barati.
     8
     9        instructionPointer() returns a MacroAssemblerCodePtr<CFunctionPtrTag>.  However,
     10        MacroAssemblerCodePtr's constructor does not accept a null pointer value and will
     11        assert accordingly with a debug ASSERT.  This is inconsequential for release
     12        builds, but to avoid this assertion failure, we should check for a null PC and
     13        return MacroAssemblerCodePtr<CFunctionPtrTag>(nullptr) instead (which uses the
     14        MacroAssemblerCodePtr(std::nullptr_t) version of the constructor instead).
     15
     16        Alternatively, we can change all of MacroAssemblerCodePtr's constructors to check
     17        for null pointers, but I rather not do that yet.  In general,
     18        MacroAssemblerCodePtrs are constructed with non-null pointers, and I prefer to
     19        leave it that way for now.
     20
     21        Note: this assertion failure only manifests when we have signal traps enabled,
     22        and encounter a null pointer deref.
     23
     24        * runtime/MachineContext.h:
     25        (JSC::MachineContext::instructionPointer):
     26
    1272018-05-25  Mark Lam  <mark.lam@apple.com>
    228
  • trunk/Source/JavaScriptCore/runtime/MachineContext.h

    r231227 r232215  
    439439    void* value = instructionPointerImpl(const_cast<PlatformRegisters&>(regs));
    440440#endif
     441    if (!value)
     442        return MacroAssemblerCodePtr<CFunctionPtrTag>(nullptr);
    441443    return MacroAssemblerCodePtr<CFunctionPtrTag>(value);
    442444}
Note: See TracChangeset for help on using the changeset viewer.