From 2b01ffe5526ff90b3cad85b2430825f0a0733651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 3 Oct 2013 15:17:41 +0200 Subject: [PATCH] iOS: Use PROT_READ, not PROT_NONE, for custom stack memory guard This allows V4 and other garbage collectors to pass through our custom stack during the mark-phase without triggering access violations. Change-Id: Icafcf4df3537c628c641fe694bb9fe2016519a83 Reviewed-by: Simon Hausmann --- src/plugins/platforms/ios/qioseventdispatcher.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm index 6148338000e..3de7c996f55 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.mm +++ b/src/plugins/platforms/ios/qioseventdispatcher.mm @@ -148,8 +148,10 @@ namespace // Add memory guard at the end of the reserved stack, so that any stack // overflow during the user's main will trigger an exception at that point, // and not when we return and find that the current stack has been smashed. + // We allow read though, so that garbage-collection can pass through our + // stack in its mark phase without triggering access violations. uintptr_t memoryGuardStart = qAlignUp(memoryStart, kPageSize); - if (mprotect((void*)memoryGuardStart, kPageSize, PROT_NONE)) + if (mprotect((void*)memoryGuardStart, kPageSize, PROT_READ)) qWarning() << "Failed to add memory guard:" << strerror(errno); // We don't consider the memory guard part of the usable stack space