- Revision
- 258857
- Author
- [email protected]
- Date
- 2020-03-23 10:34:43 -0700 (Mon, 23 Mar 2020)
Log 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 <[email protected]> on 2020-03-23
Reviewed by Mark Lam.
Source/_javascript_Core:
* 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:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (258856 => 258857)
--- trunk/Source/_javascript_Core/ChangeLog 2020-03-23 17:00:16 UTC (rev 258856)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-03-23 17:34:43 UTC (rev 258857)
@@ -1,3 +1,15 @@
+2020-03-23 Michael Catanzaro <[email protected]>
+
+ REGRESSION(r249808): [GTK] Crash in JSC Config::permanentlyFreeze() on architecture ppc64el
+ https://bugs.webkit.org/show_bug.cgi?id=209236
+
+ Reviewed by Mark Lam.
+
+ * heap/MarkedBlock.h: Use new CeilingOnPageSize.
+ * runtime/JSCConfig.cpp:
+ (JSC::Config::permanentlyFreeze): Use pageSize instead of vmPageSize.
+ * runtime/JSCConfig.h: Use new CeilingOnPageSize.
+
2020-03-22 Yusuke Suzuki <[email protected]>
Unreviewed, rename keepAlive to ensureStillAliveHere
Modified: trunk/Source/_javascript_Core/heap/MarkedBlock.h (258856 => 258857)
--- trunk/Source/_javascript_Core/heap/MarkedBlock.h 2020-03-23 17:00:16 UTC (rev 258856)
+++ trunk/Source/_javascript_Core/heap/MarkedBlock.h 2020-03-23 17:34:43 UTC (rev 258857)
@@ -26,10 +26,12 @@
#include "HeapCell.h"
#include "IterationStatus.h"
#include "WeakSet.h"
+#include <algorithm>
#include <wtf/Atomics.h>
#include <wtf/Bitmap.h>
+#include <wtf/CountingLock.h>
#include <wtf/HashFunctions.h>
-#include <wtf/CountingLock.h>
+#include <wtf/PageBlock.h>
#include <wtf/StdLibExtras.h>
namespace JSC {
@@ -70,11 +72,7 @@
static constexpr size_t atomSize = 16; // bytes
// Block size must be at least as large as the system page size.
-#if CPU(PPC64) || CPU(PPC64LE) || CPU(PPC) || CPU(UNKNOWN)
- static constexpr size_t blockSize = 64 * KB;
-#else
- static constexpr size_t blockSize = 16 * KB;
-#endif
+ static constexpr size_t blockSize = std::max(16 * KB, CeilingOnPageSize);
static constexpr size_t blockMask = ~(blockSize - 1); // blockSize must be a power of two.
Modified: trunk/Source/_javascript_Core/runtime/JSCConfig.cpp (258856 => 258857)
--- trunk/Source/_javascript_Core/runtime/JSCConfig.cpp 2020-03-23 17:00:16 UTC (rev 258856)
+++ trunk/Source/_javascript_Core/runtime/JSCConfig.cpp 2020-03-23 17:34:43 UTC (rev 258857)
@@ -53,9 +53,7 @@
void Config::permanentlyFreeze()
{
-#if PLATFORM(COCOA)
- RELEASE_ASSERT(roundUpToMultipleOf(vmPageSize(), ConfigSizeToProtect) == ConfigSizeToProtect);
-#endif
+ RELEASE_ASSERT(roundUpToMultipleOf(pageSize(), ConfigSizeToProtect) == ConfigSizeToProtect);
if (!g_jscConfig.isPermanentlyFrozen)
g_jscConfig.isPermanentlyFrozen = true;
Modified: trunk/Source/_javascript_Core/runtime/JSCConfig.h (258856 => 258857)
--- trunk/Source/_javascript_Core/runtime/JSCConfig.h 2020-03-23 17:00:16 UTC (rev 258856)
+++ trunk/Source/_javascript_Core/runtime/JSCConfig.h 2020-03-23 17:34:43 UTC (rev 258857)
@@ -26,6 +26,7 @@
#pragma once
#include "OptionsList.h"
+#include <wtf/PageBlock.h>
#include <wtf/StdLibExtras.h>
namespace JSC {
@@ -34,11 +35,7 @@
class FixedVMPoolExecutableAllocator;
class VM;
-#if !OS(WINDOWS)
-constexpr size_t ConfigSizeToProtect = 16 * KB;
-#else
-constexpr size_t ConfigSizeToProtect = 4 * KB;
-#endif
+constexpr size_t ConfigSizeToProtect = CeilingOnPageSize;
#if ENABLE(SEPARATED_WX_HEAP)
using JITWriteSeparateHeapsFunction = void (*)(off_t, const void*, size_t);
Modified: trunk/Source/WTF/ChangeLog (258856 => 258857)
--- trunk/Source/WTF/ChangeLog 2020-03-23 17:00:16 UTC (rev 258856)
+++ trunk/Source/WTF/ChangeLog 2020-03-23 17:34:43 UTC (rev 258857)
@@ -1,3 +1,22 @@
+2020-03-23 Michael Catanzaro <[email protected]>
+
+ REGRESSION(r249808): [GTK] Crash in JSC Config::permanentlyFreeze() on architecture ppc64el
+ https://bugs.webkit.org/show_bug.cgi?id=209236
+
+ Reviewed by Mark Lam.
+
+ 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:
+
2020-03-23 Jacob Uphoff <[email protected]>
Unreviewed, reverting r258803.
Modified: trunk/Source/WTF/wtf/PageBlock.cpp (258856 => 258857)
--- trunk/Source/WTF/wtf/PageBlock.cpp 2020-03-23 17:00:16 UTC (rev 258856)
+++ trunk/Source/WTF/wtf/PageBlock.cpp 2020-03-23 17:34:43 UTC (rev 258857)
@@ -44,7 +44,7 @@
inline size_t systemPageSize()
{
- return getpagesize();
+ return sysconf(_SC_PAGESIZE);
}
#elif OS(WINDOWS)
@@ -62,9 +62,11 @@
size_t pageSize()
{
- if (!s_pageSize)
+ if (!s_pageSize) {
s_pageSize = systemPageSize();
- ASSERT(isPowerOfTwo(s_pageSize));
+ RELEASE_ASSERT(isPowerOfTwo(s_pageSize));
+ RELEASE_ASSERT_WITH_MESSAGE(s_pageSize <= CeilingOnPageSize, "CeilingOnPageSize is too low, raise it in PageBlock.h!");
+ }
return s_pageSize;
}
Modified: trunk/Source/WTF/wtf/PageBlock.h (258856 => 258857)
--- trunk/Source/WTF/wtf/PageBlock.h 2020-03-23 17:00:16 UTC (rev 258856)
+++ trunk/Source/WTF/wtf/PageBlock.h 2020-03-23 17:34:43 UTC (rev 258857)
@@ -25,8 +25,38 @@
#pragma once
+#include <wtf/StdLibExtras.h>
+
namespace WTF {
+// We attempt to guess a value that is *AT LEAST* as large as the system's actual page size.
+// This is impossible to do correctly at build time, but JSC really needs it at build time, so
+// we have a RELEASE_ASSERT() inside WTF::pageSize to make sure it is set properly at runtime.
+// All of these values are going to be incorrect on systems configured to use larger than normal
+// page size, so on such systems it is expected that WebKit will crash until this value is changed
+// and recompiled. Sorry.
+//
+// macOS x86_64 uses 4 KiB, but Apple's aarch64 systems use 16 KiB. Use 16 KiB on all Apple systems
+// for consistency.
+//
+// Most Linux and Windows systems use a page size of 4 KiB.
+//
+// On Linux, Power systems normally use 64 KiB pages.
+//
+// aarch64 systems seem to be all over the place. Most Linux distros use 4 KiB, but RHEL uses
+// 64 KiB. (Apple uses 16 KiB.)
+//
+// Use 64 KiB for any unknown CPUs to be conservative.
+#if OS(DARWIN)
+constexpr size_t CeilingOnPageSize = 16 * KB;
+#elif OS(WINDOWS) || CPU(MIPS) || CPU(X86) || CPU(X86_64) || CPU(ARM)
+constexpr size_t CeilingOnPageSize = 4 * KB;
+#elif CPU(UNKNOWN) || CPU(PPC) || CPU(PPC64) || CPU(PPC64LE) || CPU(ARM64)
+constexpr size_t CeilingOnPageSize = 64 * KB;
+#else
+#error Must set CeilingOnPageSize in PageBlock.h when adding a new CPU architecture!
+#endif
+
WTF_EXPORT_PRIVATE size_t pageSize();
WTF_EXPORT_PRIVATE size_t pageMask();
inline bool isPageAligned(void* address) { return !(reinterpret_cast<intptr_t>(address) & (pageSize() - 1)); }
@@ -80,6 +110,7 @@
} // namespace WTF
+using WTF::CeilingOnPageSize;
using WTF::pageSize;
using WTF::isPageAligned;
using WTF::isPowerOfTwo;