Fix deadlock by reducing lock scope
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 37s
Builds / ExectOS (amd64, debug) (push) Successful in 38s
Builds / ExectOS (i686, release) (push) Successful in 29s
Builds / ExectOS (i686, debug) (push) Successful in 30s

This commit is contained in:
2026-01-05 01:28:09 +01:00
parent 46576398a2
commit e66baa0da0

View File

@@ -165,21 +165,24 @@ MM::KernelPool::FreeKernelStack(IN PVOID Stack,
/* Convert the stack size into a page count */
StackPages = SIZE_TO_PAGES(StackSize);
/* Acquire the PFN database lock */
KE::QueuedSpinLockGuard SpinLock(SystemSpaceLock);
/* Loop through each page of the stack that needs to be freed */
for(Index = 0; Index < StackPages; Index++)
/* Start guarded code block */
{
/* Ensure the PTE is valid */
if(MM::Paging::PteValid(PointerPte))
{
/* Free the physical page */
MM::Pfn::FreePhysicalPage(PointerPte);
}
/* Acquire the PFN database lock */
KE::QueuedSpinLockGuard SpinLock(SystemSpaceLock);
/* Advance to the next PTE */
PointerPte = MM::Paging::AdvancePte(PointerPte, -1);
/* Loop through each page of the stack that needs to be freed */
for(Index = 0; Index < StackPages; Index++)
{
/* Ensure the PTE is valid */
if(MM::Paging::PteValid(PointerPte))
{
/* Free the physical page */
MM::Pfn::FreePhysicalPage(PointerPte);
}
/* Advance to the next PTE */
PointerPte = MM::Paging::AdvancePte(PointerPte, -1);
}
}
/* Release all system PTEs used by the stack, including the guard page */