* PS1: clamp the stack size, so it doesn't exceed the maximum memory available (minus 1k for heap)

This commit is contained in:
Nikolay Nikolov 2024-10-05 00:41:40 +03:00
parent 73aa2fd266
commit 94e399faf7

View File

@ -109,8 +109,16 @@ begin
end;
function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;
const
MinHeap = 1024; // always leave at least 1k heap
var
MaxStack: SizeInt;
begin
result:= stklen;
MaxStack:=SizeInt(PtrUInt($80200000)-PtrUInt(@bss_end))-MinHeap;
if stklen<MaxStack then
result:= stklen
else
result:=MaxStack;
end;
procedure system_exit;