Author: axeld Date: 2009-11-17 15:56:51 +0100 (Tue, 17 Nov 2009) New Revision: 34090 Changeset: http://dev.haiku-os.org/changeset/34090/haiku Ticket: http://dev.haiku-os.org/ticket/4957 Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp Log: * 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. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2009-11-17 14:54:32 UTC (rev 34089) +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2009-11-17 14:56:51 UTC (rev 34090) @@ -383,6 +383,10 @@ 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 @@ // 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(); }