Changeset 258857 in webkit


Ignore:
Timestamp:
Mar 23, 2020 10:34:43 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

REGRESSION(r249808): [GTK] Crash in JSC Config::permanentlyFreeze() on architecture ppc64el
https://bugs.webkit.org/show_bug.cgi?id=209236

Patch by Michael Catanzaro <Michael Catanzaro> on 2020-03-23
Reviewed by Mark Lam.

Source/JavaScriptCore:

  • heap/MarkedBlock.h: Use new CeilingOnPageSize.
  • runtime/JSCConfig.cpp:

(JSC::Config::permanentlyFreeze): Use pageSize instead of vmPageSize.

  • runtime/JSCConfig.h: Use new CeilingOnPageSize.

Source/WTF:

Add new CeilingOnPageSize constants, for use in JSC, in order to centralize our compile-time
page size guessing into one place. Improve the implementation of pageSize() to
RELEASE_ASSERT() when CeilingOnPageSize is wrong, so we can detect and fix it if so. (It
will be even easier to detect if we change RELEASE_ASSERT_WITH_MESSAGE() to actually print
its message in release builds.) Change pageSize() to use sysconf(_SC_PAGESIZE), which is
specified by POSIX, instead of getpagesize(), which is nonstandard.

  • wtf/PageBlock.cpp:

(WTF::systemPageSize):
(WTF::pageSize):

  • wtf/PageBlock.h:
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r258825 r258857  
     12020-03-23  Michael Catanzaro  <mcatanzaro@gnome.org>
     2
     3        REGRESSION(r249808): [GTK] Crash in JSC Config::permanentlyFreeze() on architecture ppc64el
     4        https://bugs.webkit.org/show_bug.cgi?id=209236
     5
     6        Reviewed by Mark Lam.
     7
     8        * heap/MarkedBlock.h: Use new CeilingOnPageSize.
     9        * runtime/JSCConfig.cpp:
     10        (JSC::Config::permanentlyFreeze): Use pageSize instead of vmPageSize.
     11        * runtime/JSCConfig.h: Use new CeilingOnPageSize.
     12
    1132020-03-22  Yusuke Suzuki  <ysuzuki@apple.com>
    214
  • trunk/Source/JavaScriptCore/heap/MarkedBlock.h

    r254087 r258857  
    2727#include "IterationStatus.h"
    2828#include "WeakSet.h"
     29#include <algorithm>
    2930#include <wtf/Atomics.h>
    3031#include <wtf/Bitmap.h>
     32#include <wtf/CountingLock.h>
    3133#include <wtf/HashFunctions.h>
    32 #include <wtf/CountingLock.h>
     34#include <wtf/PageBlock.h>
    3335#include <wtf/StdLibExtras.h>
    3436
     
    7173
    7274    // Block size must be at least as large as the system page size.
    73 #if CPU(PPC64) || CPU(PPC64LE) || CPU(PPC) || CPU(UNKNOWN)
    74     static constexpr size_t blockSize = 64 * KB;
    75 #else
    76     static constexpr size_t blockSize = 16 * KB;
    77 #endif
     75    static constexpr size_t blockSize = std::max(16 * KB, CeilingOnPageSize);
    7876
    7977    static constexpr size_t blockMask = ~(blockSize - 1); // blockSize must be a power of two.
  • trunk/Source/JavaScriptCore/runtime/JSCConfig.cpp

    r258460 r258857  
    5454void Config::permanentlyFreeze()
    5555{
    56 #if PLATFORM(COCOA)
    57     RELEASE_ASSERT(roundUpToMultipleOf(vmPageSize(), ConfigSizeToProtect) == ConfigSizeToProtect);
    58 #endif
     56    RELEASE_ASSERT(roundUpToMultipleOf(pageSize(), ConfigSizeToProtect) == ConfigSizeToProtect);
    5957
    6058    if (!g_jscConfig.isPermanentlyFrozen)
  • trunk/Source/JavaScriptCore/runtime/JSCConfig.h

    r258463 r258857  
    2727
    2828#include "OptionsList.h"
     29#include <wtf/PageBlock.h>
    2930#include <wtf/StdLibExtras.h>
    3031
     
    3536class VM;
    3637
    37 #if !OS(WINDOWS)
    38 constexpr size_t ConfigSizeToProtect = 16 * KB;
    39 #else
    40 constexpr size_t ConfigSizeToProtect = 4 * KB;
    41 #endif
     38constexpr size_t ConfigSizeToProtect = CeilingOnPageSize;
    4239
    4340#if ENABLE(SEPARATED_WX_HEAP)
  • trunk/Source/WTF/ChangeLog

    r258841 r258857  
     12020-03-23  Michael Catanzaro  <mcatanzaro@gnome.org>
     2
     3        REGRESSION(r249808): [GTK] Crash in JSC Config::permanentlyFreeze() on architecture ppc64el
     4        https://bugs.webkit.org/show_bug.cgi?id=209236
     5
     6        Reviewed by Mark Lam.
     7
     8        Add new CeilingOnPageSize constants, for use in JSC, in order to centralize our compile-time
     9        page size guessing into one place. Improve the implementation of pageSize() to
     10        RELEASE_ASSERT() when CeilingOnPageSize is wrong, so we can detect and fix it if so. (It
     11        will be even easier to detect if we change RELEASE_ASSERT_WITH_MESSAGE() to actually print
     12        its message in release builds.) Change pageSize() to use sysconf(_SC_PAGESIZE), which is
     13        specified by POSIX, instead of getpagesize(), which is nonstandard.
     14
     15        * wtf/PageBlock.cpp:
     16        (WTF::systemPageSize):
     17        (WTF::pageSize):
     18        * wtf/PageBlock.h:
     19
    1202020-03-23  Jacob Uphoff  <jacob_uphoff@apple.com>
    221
  • trunk/Source/WTF/wtf/PageBlock.cpp

    r237099 r258857  
    4545inline size_t systemPageSize()
    4646{
    47     return getpagesize();
     47    return sysconf(_SC_PAGESIZE);
    4848}
    4949
     
    6363size_t pageSize()
    6464{
    65     if (!s_pageSize)
     65    if (!s_pageSize) {
    6666        s_pageSize = systemPageSize();
    67     ASSERT(isPowerOfTwo(s_pageSize));
     67        RELEASE_ASSERT(isPowerOfTwo(s_pageSize));
     68        RELEASE_ASSERT_WITH_MESSAGE(s_pageSize <= CeilingOnPageSize, "CeilingOnPageSize is too low, raise it in PageBlock.h!");
     69    }
    6870    return s_pageSize;
    6971}
  • trunk/Source/WTF/wtf/PageBlock.h

    r248546 r258857  
    2626#pragma once
    2727
     28#include <wtf/StdLibExtras.h>
     29
    2830namespace WTF {
     31
     32// We attempt to guess a value that is *AT LEAST* as large as the system's actual page size.
     33// This is impossible to do correctly at build time, but JSC really needs it at build time, so
     34// we have a RELEASE_ASSERT() inside WTF::pageSize to make sure it is set properly at runtime.
     35// All of these values are going to be incorrect on systems configured to use larger than normal
     36// page size, so on such systems it is expected that WebKit will crash until this value is changed
     37// and recompiled. Sorry.
     38//
     39// macOS x86_64 uses 4 KiB, but Apple's aarch64 systems use 16 KiB. Use 16 KiB on all Apple systems
     40// for consistency.
     41//
     42// Most Linux and Windows systems use a page size of 4 KiB.
     43//
     44// On Linux, Power systems normally use 64 KiB pages.
     45//
     46// aarch64 systems seem to be all over the place. Most Linux distros use 4 KiB, but RHEL uses
     47// 64 KiB. (Apple uses 16 KiB.)
     48//
     49// Use 64 KiB for any unknown CPUs to be conservative.
     50#if OS(DARWIN)
     51constexpr size_t CeilingOnPageSize = 16 * KB;
     52#elif OS(WINDOWS) || CPU(MIPS) || CPU(X86) || CPU(X86_64) || CPU(ARM)
     53constexpr size_t CeilingOnPageSize = 4 * KB;
     54#elif CPU(UNKNOWN) || CPU(PPC) || CPU(PPC64) || CPU(PPC64LE) || CPU(ARM64)
     55constexpr size_t CeilingOnPageSize = 64 * KB;
     56#else
     57#error Must set CeilingOnPageSize in PageBlock.h when adding a new CPU architecture!
     58#endif
    2959
    3060WTF_EXPORT_PRIVATE size_t pageSize();
     
    81111} // namespace WTF
    82112
     113using WTF::CeilingOnPageSize;
    83114using WTF::pageSize;
    84115using WTF::isPageAligned;
Note: See TracChangeset for help on using the changeset viewer.