diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-09-02 15:23:14 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-09-07 20:54:04 +0000 |
commit | 6c64a3c4ff5c8fae65e28a428f398f9b01eeb2bf (patch) | |
tree | b618e4d086921ec46fe8b666f2a3a2e2c37d2ae8 /src | |
parent | 24a31c9e50f5f8bf8be1ddd4f98645cd3662dbe4 (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)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index ff85299752..80ef6bf39f 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -434,12 +434,15 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine) } } + // We allocate guard pages around our stacks. + const size_t guardPages = 2 * WTF::pageSize(); + memoryManager = new QV4::MemoryManager(this); // 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( - s_maxJSStackSize + 256*1024, WTF::OSAllocator::JSVMStackPages, + s_maxJSStackSize + 256*1024 + guardPages, WTF::OSAllocator::JSVMStackPages, /* writable */ true, /* executable */ false, /* includesGuardPages */ true); jsStackBase = (Value *)jsStack->base(); #ifdef V4_USE_VALGRIND @@ -448,9 +451,9 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine) jsStackTop = jsStackBase; - *gcStack = WTF::PageAllocation::allocate(s_maxGCStackSize, WTF::OSAllocator::JSVMStackPages, - /* writable */ true, /* executable */ false, - /* includesGuardPages */ true); + *gcStack = WTF::PageAllocation::allocate( + s_maxGCStackSize + guardPages, WTF::OSAllocator::JSVMStackPages, + /* writable */ true, /* executable */ false, /* includesGuardPages */ true); exceptionValue = jsAlloca(1); *exceptionValue = Encode::undefined(); |