Changeset 262830 in webkit


Ignore:
Timestamp:
Jun 9, 2020, 7:04:14 PM (5 years ago)
Author:
mark.lam@apple.com
Message:

Stringifier::appendStringifiedValue() should not assume it is always safe to recurse.
https://bugs.webkit.org/show_bug.cgi?id=213006
<rdar://problem/64154840>

Reviewed by Keith Miller.

JSTests:

  • stress/json-stringify-executing-in-reserved-zone.js: Added.

Source/JavaScriptCore:

In r262727, I suggested that Alexey Shvayka add an assertion in
Stringifier::appendStringifiedValue() to assert that it is safe to recurse because
we don't expect it to recurse into itself. Turns out this is a bad idea because
a client may be doing the recursing before calling Stringifier::appendStringifiedValue().
As a result, Stringifier::appendStringifiedValue() ends up being executed with
the stack pointer already in the reserved zone. This is legal, and is what the
reserved zone is intended for as long as we don't recurse from here. However,
this also means that asserting vm.isSafeToRecurseSoft() here will surely fail
because we are already in the reserved zone area. The fix is simply to remove
this faulty assertion.

  • runtime/JSONObject.cpp:

(JSC::Stringifier::appendStringifiedValue):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r262827 r262830  
     12020-06-09  Mark Lam  <mark.lam@apple.com>
     2
     3        Stringifier::appendStringifiedValue() should not assume it is always safe to recurse.
     4        https://bugs.webkit.org/show_bug.cgi?id=213006
     5        <rdar://problem/64154840>
     6
     7        Reviewed by Keith Miller.
     8
     9        * stress/json-stringify-executing-in-reserved-zone.js: Added.
     10
    1112020-06-09  Mark Lam  <mark.lam@apple.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r262827 r262830  
     12020-06-09  Mark Lam  <mark.lam@apple.com>
     2
     3        Stringifier::appendStringifiedValue() should not assume it is always safe to recurse.
     4        https://bugs.webkit.org/show_bug.cgi?id=213006
     5        <rdar://problem/64154840>
     6
     7        Reviewed by Keith Miller.
     8
     9        In r262727, I suggested that Alexey Shvayka add an assertion in
     10        Stringifier::appendStringifiedValue() to assert that it is safe to recurse because
     11        we don't expect it to recurse into itself.  Turns out this is a bad idea because
     12        a client may be doing the recursing before calling Stringifier::appendStringifiedValue().
     13        As a result, Stringifier::appendStringifiedValue() ends up being executed with
     14        the stack pointer already in the reserved zone.  This is legal, and is what the
     15        reserved zone is intended for as long as we don't recurse from here.  However,
     16        this also means that asserting vm.isSafeToRecurseSoft() here will surely fail
     17        because we are already in the reserved zone area.  The fix is simply to remove
     18        this faulty assertion.
     19
     20        * runtime/JSONObject.cpp:
     21        (JSC::Stringifier::appendStringifiedValue):
     22
    1232020-06-09  Mark Lam  <mark.lam@apple.com>
    224
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r262727 r262830  
    11/*
    2  * Copyright (C) 2009-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    315315
    316316    // Recursion is avoided by !holderStackWasEmpty check and do/while loop at the end of this method.
    317     ASSERT(vm.isSafeToRecurseSoft());
     317    // We're having this recursion check here as a fail safe in case the code
     318    // below get modified such that recursion is no longer avoided.
    318319    if (UNLIKELY(!vm.isSafeToRecurseSoft())) {
    319320        throwStackOverflowError(m_globalObject, scope);
Note: See TracChangeset for help on using the changeset viewer.