aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-09-02 15:23:14 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-09-09 12:24:38 +0200
commitd9fe92c7f72c7d7610dd960ee42479a64cf26bee (patch)
treee0aa3b8e3258f85ed9366f966a13fd6d68f60e5c
parentb9d45368d778cc81509877dde143a6abe5f2e5cb (diff)
V4: Account for the guard pages when allocating stack space
Previously we've assumed the whole allocation can be used, even though the first and the last page are actually not usable. This makes a difference when the size of the guard pages grows, such as on macOS, which these days has 16k pages. Add the extra guard page size to the amount of memory to be allocated in order to fix the calculation. Fixes: QTBUG-93188 Change-Id: I0ebece94449da3127e9a78a19d8a22722ad8d698 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 826b77c8cf0ffbef4f95e7b9e72eb9dc25936657)
-rw-r--r--src/qml/jsruntime/qv4engine.cpp15
-rw-r--r--tests/auto/qml/qqmlecmascript/BLACKLIST2
2 files changed, 9 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 828d755e0e..bf5d437d10 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -300,6 +300,9 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
if (ok && envMaxGCStackSize > 0)
m_maxGCStackSize = envMaxGCStackSize;
+ // We allocate guard pages around our stacks.
+ const size_t guardPages = 2 * WTF::pageSize();
+
memoryManager = new QV4::MemoryManager(this);
if (maxCallDepth == -1) {
@@ -327,9 +330,9 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
// reserve space for the JS stack
// we allow it to grow to a bit more than m_maxJSStackSize, as we can overshoot due to ScopedValues
// allocated outside of JIT'ed methods.
- *jsStack = WTF::PageAllocation::allocate(m_maxJSStackSize + 256*1024, WTF::OSAllocator::JSVMStackPages,
- /* writable */ true, /* executable */ false,
- /* includesGuardPages */ true);
+ *jsStack = WTF::PageAllocation::allocate(
+ m_maxJSStackSize + 256*1024 + guardPages, WTF::OSAllocator::JSVMStackPages,
+ /* writable */ true, /* executable */ false, /* includesGuardPages */ true);
jsStackBase = (Value *)jsStack->base();
#ifdef V4_USE_VALGRIND
VALGRIND_MAKE_MEM_UNDEFINED(jsStackBase, m_maxJSStackSize + 256*1024);
@@ -337,9 +340,9 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
jsStackTop = jsStackBase;
- *gcStack = WTF::PageAllocation::allocate(m_maxGCStackSize, WTF::OSAllocator::JSVMStackPages,
- /* writable */ true, /* executable */ false,
- /* includesGuardPages */ true);
+ *gcStack = WTF::PageAllocation::allocate(
+ m_maxGCStackSize + guardPages, WTF::OSAllocator::JSVMStackPages,
+ /* writable */ true, /* executable */ false, /* includesGuardPages */ true);
{
ok = false;
diff --git a/tests/auto/qml/qqmlecmascript/BLACKLIST b/tests/auto/qml/qqmlecmascript/BLACKLIST
deleted file mode 100644
index bd25566eef..0000000000
--- a/tests/auto/qml/qqmlecmascript/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[gcCrashRegressionTest]
-macos arm