kernel/thread: Change owner_process to std::weak_ptr (#5325)

* kernel/thread: Change owner_process to std::weak_ptr

Previously this leaked almost all kernel objects. In short, Threads own Processes which own HandleTables which own maps of Objects which include Threads.

Changing this to weak_ptr at least got the camera interfaces to destruct properly. Did not really check the other objects though, and I think there are probably more leaks.

* hle/kernel: Lock certain objects while deserializing

When deserializing other kernel objects, these objects (`MemoryRegion`s and `VMManager`s) can possibly get modified. To avoid inconsistent state caused by destructor side-effects, we may as well simply lock them until loading is fully completed.

* Fix silly typo

Somehow this didn't break?!
This commit is contained in:
Pengfei Zhu
2020-11-15 12:59:45 +01:00
committed by GitHub
parent 80c9f9abbb
commit de3d7cf49f
13 changed files with 121 additions and 31 deletions
+12
View File
@@ -26,6 +26,10 @@ struct MemoryRegionInfo {
IntervalSet free_blocks;
// When locked, Free calls will be ignored, while Allocate calls will hit an assert. A memory
// region locks itself after deserialization.
bool is_locked{};
/**
* Reset the allocator state
* @param base The base offset the beginning of FCRAM.
@@ -63,6 +67,11 @@ struct MemoryRegionInfo {
*/
void Free(u32 offset, u32 size);
/**
* Unlock the MemoryRegion. Used after loading is completed.
*/
void Unlock();
private:
friend class boost::serialization::access;
template <class Archive>
@@ -71,6 +80,9 @@ private:
ar& size;
ar& used;
ar& free_blocks;
if (Archive::is_loading::value) {
is_locked = true;
}
}
};