From efe70b3b3e8bd4e1d5701688eadd3491a4196e4a Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Tue, 12 Mar 2013 21:29:19 +0100 Subject: [PATCH] Avoid physical frame stack overflow. --- sortix/x86-family/memorymanagement.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sortix/x86-family/memorymanagement.cpp b/sortix/x86-family/memorymanagement.cpp index 4f39a8d2..8fcef292 100644 --- a/sortix/x86-family/memorymanagement.cpp +++ b/sortix/x86-family/memorymanagement.cpp @@ -239,7 +239,7 @@ namespace Sortix { // This call will always succeed, if it didn't, then the stack // wouldn't be full, and thus this function won't be called. - addr_t page = Get(); + addr_t page = GetUnlocked(); // This call will also succeed, since there are plenty of physical // pages available and it might need some. @@ -350,7 +350,15 @@ namespace Sortix void PutUnlocked(addr_t page) { assert(page == AlignDown(page)); - assert(stackused < MAXSTACKLENGTH); + if ( unlikely(stackused == stacklength) ) + { + if ( stackused == MAXSTACKLENGTH ) + { + pagesnotonstack++; + return; + } + ExtendStack(); + } STACK[stackused++] = page; }