Fix crash bugs

This commit is contained in:
Hamish Milne 2020-01-06 23:20:18 +00:00 committed by zhupengfei
parent 116d22d562
commit f2de70c3fb
8 changed files with 32 additions and 21 deletions

View file

@ -123,7 +123,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set up output paths for executable binaries # set up output paths for executable binaries
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE})
# System imported libraries # System imported libraries

14
TODO
View file

@ -1,6 +1,11 @@
☐ Save/load UI ☐ Save/load UI
✔ Basic version @done(20-01-03 15:27) ✔ Basic version @done(20-01-03 15:27)
☐ Multiple slots etc. ☐ Multiple slots etc.
☐ Custom texture cache
☐ Review constructor/initialization code
☐ Review core timing events
☐ Review base class serialization everywhere
☐ Serialize codeset with an apploader reference instead
✔ CPU @done(19-08-13 15:41) ✔ CPU @done(19-08-13 15:41)
✔ Memory @done(19-08-13 15:41) ✔ Memory @done(19-08-13 15:41)
✔ Page tables @done(20-01-05 16:33) ✔ Page tables @done(20-01-05 16:33)
@ -32,7 +37,6 @@
Not needed as nothing serializes file buffers Not needed as nothing serializes file buffers
✘ Replace delay generator with virtual fns @cancelled(20-01-03 13:16) ✘ Replace delay generator with virtual fns @cancelled(20-01-03 13:16)
While they have no state, the extra refactoring here is unneeded While they have no state, the extra refactoring here is unneeded
☐ Custom texture cache
✘ MMIO @cancelled(20-01-01 01:06) ✘ MMIO @cancelled(20-01-01 01:06)
Seems that this whole subsystem is only used in tests Seems that this whole subsystem is only used in tests
✘ Movie @cancelled(20-01-01 01:07) ✘ Movie @cancelled(20-01-01 01:07)
@ -44,9 +48,6 @@
✘ Telemetry session @cancelled(20-01-01 01:12) ✘ Telemetry session @cancelled(20-01-01 01:12)
Doesn't need to be serialized here Doesn't need to be serialized here
✔ Replace SERIALIZE_AS_POD with BOOST_IS_BITWISE_SERIALIZABLE @started(20-01-03 13:47) @done(20-01-03 13:58) @lasted(11m22s) ✔ Replace SERIALIZE_AS_POD with BOOST_IS_BITWISE_SERIALIZABLE @started(20-01-03 13:47) @done(20-01-03 13:58) @lasted(11m22s)
☐ Review constructor/initialization code
☐ Review core timing events
☐ Review base class serialization everywhere
✔ Fix CI @done(19-12-31 21:32) ✔ Fix CI @done(19-12-31 21:32)
✔ HW @done(19-08-13 15:41) ✔ HW @done(19-08-13 15:41)
✔ GPU regs @done(19-08-13 15:41) ✔ GPU regs @done(19-08-13 15:41)
@ -57,8 +58,8 @@
✔ PICA state @done(19-08-13 15:41) ✔ PICA state @done(19-08-13 15:41)
✔ Primitive assembly @done(19-12-22 16:05) ✔ Primitive assembly @done(19-12-22 16:05)
✔ Shader @done(19-08-13 16:03) ✔ Shader @done(19-08-13 16:03)
☐ HLE @started(19-08-13 16:43) ✔ HLE @started(19-08-13 16:43) @done(20-01-06 20:37) @lasted(20w6d4h54m19s)
☐ Kernel @started(19-08-13 16:43) ✔ Kernel @started(19-08-13 16:43) @done(20-01-06 20:37) @lasted(20w6d4h54m17s)
Most of these require adding Core::Global Most of these require adding Core::Global
✔ Address arbiter @done(19-08-13 16:40) ✔ Address arbiter @done(19-08-13 16:40)
✔ Client port @done(19-08-13 16:40) ✔ Client port @done(19-08-13 16:40)
@ -74,7 +75,6 @@
✔ Process @started(19-08-13 16:43) @done(19-12-22 18:41) ✔ Process @started(19-08-13 16:43) @done(19-12-22 18:41)
✔ Code set @started(19-12-22 18:41) @done(20-01-03 15:15) @lasted(1w4d20h34m2s) ✔ Code set @started(19-12-22 18:41) @done(20-01-03 15:15) @lasted(1w4d20h34m2s)
Needs a way to reference loaded images (so we don't serialize the entire ROM as well) Needs a way to reference loaded images (so we don't serialize the entire ROM as well)
☐ Serialize codeset with an apploader reference instead
✔ Resource limit @done(19-08-13 16:43) ✔ Resource limit @done(19-08-13 16:43)
✔ Semaphore @done(19-08-13 16:44) ✔ Semaphore @done(19-08-13 16:44)
✔ Server port @done(19-08-13 16:44) ✔ Server port @done(19-08-13 16:44)

BIN
save0.citrasave Normal file

Binary file not shown.

View file

@ -11,5 +11,4 @@ using oarchive = boost::archive::binary_oarchive;
#define SERIALIZE_EXPORT_IMPL(A) \ #define SERIALIZE_EXPORT_IMPL(A) \
BOOST_SERIALIZATION_REGISTER_ARCHIVE(iarchive) \ BOOST_SERIALIZATION_REGISTER_ARCHIVE(iarchive) \
BOOST_SERIALIZATION_REGISTER_ARCHIVE(oarchive) \ BOOST_SERIALIZATION_REGISTER_ARCHIVE(oarchive)
BOOST_CLASS_EXPORT_IMPLEMENT(A)

View file

@ -44,6 +44,8 @@
#include "network/network.h" #include "network/network.h"
#include "video_core/video_core.h" #include "video_core/video_core.h"
#include "core/hle/service/pm/pm_app.h"
namespace Core { namespace Core {
/*static*/ System System::s_instance; /*static*/ System System::s_instance;
@ -214,8 +216,8 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window, u32 system_mo
timing = std::make_unique<Timing>(); timing = std::make_unique<Timing>();
kernel = std::make_unique<Kernel::KernelSystem>(*memory, *timing, kernel = std::make_unique<Kernel::KernelSystem>(
[this] { PrepareReschedule(); }, system_mode); *memory, *timing, [this] { PrepareReschedule(); }, system_mode);
if (Settings::values.use_cpu_jit) { if (Settings::values.use_cpu_jit) {
#ifdef ARCHITECTURE_x86_64 #ifdef ARCHITECTURE_x86_64
@ -420,11 +422,17 @@ void System::serialize(Archive& ar, const unsigned int file_version) {
} }
void System::Save(std::ostream& stream) const { void System::Save(std::ostream& stream) const {
{ try {
oarchive oa{stream};
oa&* this; {
oarchive oa{stream};
oa&* this;
}
VideoCore::Save(stream);
} catch (const std::exception& e) {
LOG_ERROR(Core, "Error saving: {}", e.what());
} }
VideoCore::Save(stream);
} }
void System::Load(std::istream& stream) { void System::Load(std::istream& stream) {

View file

@ -198,7 +198,7 @@ private:
* id of the memory interface and let kernel convert it back to client vaddr. No real unmapping is * id of the memory interface and let kernel convert it back to client vaddr. No real unmapping is
* needed in this case, though. * needed in this case, though.
*/ */
class HLERequestContext : std::enable_shared_from_this<HLERequestContext> { class HLERequestContext : public std::enable_shared_from_this<HLERequestContext> {
public: public:
HLERequestContext(KernelSystem& kernel, std::shared_ptr<ServerSession> session, HLERequestContext(KernelSystem& kernel, std::shared_ptr<ServerSession> session,
std::shared_ptr<Thread> thread); std::shared_ptr<Thread> thread);

View file

@ -75,10 +75,11 @@ ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread) {
kernel.memory.ReadBlock(*current_process, thread->GetCommandBufferAddress(), cmd_buf.data(), kernel.memory.ReadBlock(*current_process, thread->GetCommandBufferAddress(), cmd_buf.data(),
cmd_buf.size() * sizeof(u32)); cmd_buf.size() * sizeof(u32));
Kernel::HLERequestContext context(kernel, SharedFrom(this), thread); auto context =
context.PopulateFromIncomingCommandBuffer(cmd_buf.data(), current_process); std::make_shared<Kernel::HLERequestContext>(kernel, SharedFrom(this), thread);
context->PopulateFromIncomingCommandBuffer(cmd_buf.data(), current_process);
hle_handler->HandleSyncRequest(context); hle_handler->HandleSyncRequest(*context);
ASSERT(thread->status == Kernel::ThreadStatus::Running || ASSERT(thread->status == Kernel::ThreadStatus::Running ||
thread->status == Kernel::ThreadStatus::WaitHleEvent); thread->status == Kernel::ThreadStatus::WaitHleEvent);
@ -86,7 +87,7 @@ ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread) {
// put the thread to sleep then the writing of the command buffer will be deferred to the // put the thread to sleep then the writing of the command buffer will be deferred to the
// wakeup callback. // wakeup callback.
if (thread->status == Kernel::ThreadStatus::Running) { if (thread->status == Kernel::ThreadStatus::Running) {
context.WriteToOutgoingCommandBuffer(cmd_buf.data(), *current_process); context->WriteToOutgoingCommandBuffer(cmd_buf.data(), *current_process);
kernel.memory.WriteBlock(*current_process, thread->GetCommandBufferAddress(), kernel.memory.WriteBlock(*current_process, thread->GetCommandBufferAddress(),
cmd_buf.data(), cmd_buf.size() * sizeof(u32)); cmd_buf.data(), cmd_buf.size() * sizeof(u32));
} }

View file

@ -452,6 +452,9 @@ MemoryRef MemorySystem::GetPhysicalRef(PAddr address) {
default: default:
UNREACHABLE(); UNREACHABLE();
} }
if (offset_into_region >= target_mem->GetSize()) {
return {nullptr};
}
return {target_mem, offset_into_region}; return {target_mem, offset_into_region};
} }