2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Merge pull request #1890 from jschmer/master

Fix Process object leak on emulation stop
This commit is contained in:
Mat M 2018-12-12 16:24:23 -05:00 committed by GitHub
commit 700075beb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 13 deletions

View file

@ -17,13 +17,13 @@ namespace Kernel {
SharedMemory::SharedMemory(KernelCore& kernel) : Object{kernel} {} SharedMemory::SharedMemory(KernelCore& kernel) : Object{kernel} {}
SharedMemory::~SharedMemory() = default; SharedMemory::~SharedMemory() = default;
SharedPtr<SharedMemory> SharedMemory::Create(KernelCore& kernel, SharedPtr<Process> owner_process, SharedPtr<SharedMemory> SharedMemory::Create(KernelCore& kernel, Process* owner_process, u64 size,
u64 size, MemoryPermission permissions, MemoryPermission permissions,
MemoryPermission other_permissions, VAddr address, MemoryPermission other_permissions, VAddr address,
MemoryRegion region, std::string name) { MemoryRegion region, std::string name) {
SharedPtr<SharedMemory> shared_memory(new SharedMemory(kernel)); SharedPtr<SharedMemory> shared_memory(new SharedMemory(kernel));
shared_memory->owner_process = std::move(owner_process); shared_memory->owner_process = owner_process;
shared_memory->name = std::move(name); shared_memory->name = std::move(name);
shared_memory->size = size; shared_memory->size = size;
shared_memory->permissions = permissions; shared_memory->permissions = permissions;

View file

@ -45,8 +45,8 @@ public:
* linear heap. * linear heap.
* @param name Optional object name, used for debugging purposes. * @param name Optional object name, used for debugging purposes.
*/ */
static SharedPtr<SharedMemory> Create(KernelCore& kernel, SharedPtr<Process> owner_process, static SharedPtr<SharedMemory> Create(KernelCore& kernel, Process* owner_process, u64 size,
u64 size, MemoryPermission permissions, MemoryPermission permissions,
MemoryPermission other_permissions, VAddr address = 0, MemoryPermission other_permissions, VAddr address = 0,
MemoryRegion region = MemoryRegion::BASE, MemoryRegion region = MemoryRegion::BASE,
std::string name = "Unknown"); std::string name = "Unknown");
@ -139,7 +139,7 @@ private:
/// Permission restrictions applied to other processes mapping the block. /// Permission restrictions applied to other processes mapping the block.
MemoryPermission other_permissions{}; MemoryPermission other_permissions{};
/// Process that created this shared memory block. /// Process that created this shared memory block.
SharedPtr<Process> owner_process; Process* owner_process;
/// Address of shared memory block in the owner process if specified. /// Address of shared memory block in the owner process if specified.
VAddr base_address = 0; VAddr base_address = 0;
/// Name of shared memory object. /// Name of shared memory object.

View file

@ -1487,9 +1487,9 @@ static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32
} }
auto& kernel = Core::System::GetInstance().Kernel(); auto& kernel = Core::System::GetInstance().Kernel();
auto& handle_table = Core::CurrentProcess()->GetHandleTable(); auto process = kernel.CurrentProcess();
const auto shared_mem_handle = SharedMemory::Create( auto& handle_table = process->GetHandleTable();
kernel, handle_table.Get<Process>(CurrentProcess), size, perms, perms, addr); const auto shared_mem_handle = SharedMemory::Create(kernel, process, size, perms, perms, addr);
CASCADE_RESULT(*handle, handle_table.Create(shared_mem_handle)); CASCADE_RESULT(*handle, handle_table.Create(shared_mem_handle));
return RESULT_SUCCESS; return RESULT_SUCCESS;
@ -1599,10 +1599,9 @@ static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permiss
} }
auto& kernel = Core::System::GetInstance().Kernel(); auto& kernel = Core::System::GetInstance().Kernel();
auto& handle_table = Core::CurrentProcess()->GetHandleTable(); auto process = kernel.CurrentProcess();
auto shared_mem_handle = auto& handle_table = process->GetHandleTable();
SharedMemory::Create(kernel, handle_table.Get<Process>(KernelHandle::CurrentProcess), size, auto shared_mem_handle = SharedMemory::Create(kernel, process, size, local_perms, remote_perms);
local_perms, remote_perms);
CASCADE_RESULT(*handle, handle_table.Create(shared_mem_handle)); CASCADE_RESULT(*handle, handle_table.Create(shared_mem_handle));
return RESULT_SUCCESS; return RESULT_SUCCESS;