fix: continue fix page fault heap regression

This commit is contained in:
2026-02-28 00:14:28 +01:00
parent ca85553eec
commit 1809ae55e5
9 changed files with 174 additions and 40 deletions
+29 -1
View File
@@ -8,6 +8,9 @@
#pragma once
#include <Sched/Scheduler.hpp>
#include <Timekeeping/ApicTimer.hpp>
#include <Memory/Paging.hpp>
#include <Memory/PageFrameAllocator.hpp>
#include <Memory/HHDM.hpp>
#include "Syscall.hpp"
#include "WinServer.hpp"
@@ -105,9 +108,34 @@ namespace Zenith {
auto* proc = Sched::GetProcessByPid(pid);
if (!proc) return -1;
// Clean up any windows owned by this process
// Clean up any windows owned by this process (unmaps pixel pages from desktop)
WinServer::CleanupProcess(pid);
// Free I/O redirect buffers
if (proc->outBuf) {
Memory::g_pfa->Free(proc->outBuf);
proc->outBuf = nullptr;
}
if (proc->inBuf) {
Memory::g_pfa->Free(proc->inBuf);
proc->inBuf = nullptr;
}
// Free all user-space pages and page table structures
Memory::VMM::Paging::FreeUserHalf(proc->pml4Phys);
// Free kernel stack (safe — killed process isn't running on single-core)
if (proc->stackBase != 0) {
Memory::g_pfa->Free((void*)proc->stackBase, Sched::StackPages);
proc->stackBase = 0;
}
// Free the PML4 page
if (proc->pml4Phys != 0) {
Memory::g_pfa->Free((void*)Memory::HHDM(proc->pml4Phys));
proc->pml4Phys = 0;
}
proc->state = Sched::ProcessState::Terminated;
return 0;
}