diff --git a/AK/Vector.h b/AK/Vector.h index 568da8ae86..00b134551d 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -164,6 +164,7 @@ public: void unchecked_append(T&& value) { + ASSERT((size() + 1) <= capacity()); new (m_impl->slot(m_impl->m_size)) T(move(value)); ++m_impl->m_size; } diff --git a/Kernel/ProcFileSystem.cpp b/Kernel/ProcFileSystem.cpp index 8a5170b526..670bc36228 100644 --- a/Kernel/ProcFileSystem.cpp +++ b/Kernel/ProcFileSystem.cpp @@ -189,7 +189,8 @@ void ProcFS::remove_process(Process& process) InterruptDisabler disabler; auto pid = process.pid(); auto it = m_pid2inode.find(pid); - ASSERT(it != m_pid2inode.end()); + if (it == m_pid2inode.end()) + return; bool success = remove_file((*it).value); ASSERT(success); m_pid2inode.remove(pid); diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 3d7cc43521..d904cf2d68 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -690,7 +690,8 @@ Process::~Process() ProcFS::the().remove_process(*this); system.nprocess--; - gdt_free_entry(selector()); + if (selector()) + gdt_free_entry(selector()); if (m_kernelStack) { kfree(m_kernelStack); diff --git a/Kernel/i386.cpp b/Kernel/i386.cpp index 0410c26afb..e752708654 100644 --- a/Kernel/i386.cpp +++ b/Kernel/i386.cpp @@ -34,7 +34,7 @@ word gdt_alloc_entry() void gdt_free_entry(word entry) { - s_gdt_freelist->append(entry); + s_gdt_freelist->unchecked_append(entry); } extern "C" void handle_irq(); diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 96b8d7f407..61a979c5b9 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -36,14 +36,13 @@ Keyboard* keyboard; static void spawn_stress() NORETURN; static void spawn_stress() { - dword lastAlloc = sum_alloc; + dword last_sum_alloc = sum_alloc; for (unsigned i = 0; i < 10000; ++i) { int error; Process::create_user_process("/bin/true", (uid_t)100, (gid_t)100, (pid_t)0, error, Vector(), Vector(), tty0); - kprintf("malloc stats: alloc:%u free:%u eternal:%u ", sum_alloc, sum_free, kmalloc_sum_eternal); - kprintf("delta:%u\n", sum_alloc - lastAlloc); - lastAlloc = sum_alloc; + dbgprintf("malloc stats: alloc:%u free:%u eternal:%u !delta:%u\n", sum_alloc, sum_free, kmalloc_sum_eternal, sum_alloc - last_sum_alloc); + last_sum_alloc = sum_alloc; sleep(60); } for (;;) {