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 <simon.hausmann@digia.com>
This commit is contained in:
Tor Arne Vestbø 2013-10-03 15:17:41 +02:00 committed by The Qt Project
parent d920af378c
commit 2b01ffe552

View File

@ -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