From 5f3d76278875888fc7b94a7e87244ad165b2ea5b Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 6 Jan 2013 15:05:16 +0000 Subject: [PATCH] * when the stack size is overestimated so much that it's larger than the stack pointer (can happen for externally started threads), truncate it to a legal value (should stop crashes when enabling stack checking on iOS 6) git-svn-id: trunk@23320 - --- rtl/bsd/system.pp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rtl/bsd/system.pp b/rtl/bsd/system.pp index 910aa449c1..9ca16aa70b 100644 --- a/rtl/bsd/system.pp +++ b/rtl/bsd/system.pp @@ -314,7 +314,12 @@ begin end; function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt; +var + stackpointer: ptruint; begin + stackpointer := (ptruint(sptr) + 4095) and not(4095); + if stklen > stackpointer then + stklen := stackpointer-4096; result := stklen; end;