From 931d8b07e8f360f4f6b4aa89a48907c59e17e8a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 17 Nov 2009 14:56:51 +0000 Subject: [PATCH] * Reverted r32216 (by mmlr): it's not a good idea to access a variable on the stack after that has just been changed, and does not contain the data one would assume. * This fixes the leaking the vm_translation_map_arch_info objects, and thus bug #4957. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34090 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/arch/x86/arch_thread.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/system/kernel/arch/x86/arch_thread.cpp b/src/system/kernel/arch/x86/arch_thread.cpp index 620eba7b9f..60e0a57f08 100644 --- a/src/system/kernel/arch/x86/arch_thread.cpp +++ b/src/system/kernel/arch/x86/arch_thread.cpp @@ -383,6 +383,10 @@ arch_thread_context_switch(struct thread *from, struct thread *to) atomic_and(&activeMap->active_on_cpus, ~((uint32)1 << cpu)); atomic_or(&toMap->active_on_cpus, (uint32)1 << cpu); + activeMap->RemoveReference(); + // this might causes the map to be deferred deleted - ie. it won't + // be deleted when it is still in use + // assign the new map to the CPU toMap->AddReference(); cpuData->arch.active_translation_map = toMap; @@ -390,15 +394,12 @@ arch_thread_context_switch(struct thread *from, struct thread *to) // get the new page directory newPageDirectory = (addr_t)toMap->pgdir_phys; } else { - activeMap = NULL; newPageDirectory = 0; + // this means no change } gX86SwapFPUFunc(from->arch_info.fpu_state, to->arch_info.fpu_state); i386_context_switch(&from->arch_info, &to->arch_info, newPageDirectory); - - if (activeMap != NULL) - activeMap->RemoveReference(); }