From 656db6c6687d7df84b6c8a11aeaebadf4775b955 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 10 Mar 2020 22:37:11 +0300 Subject: [PATCH 1/3] Fatal errors: concatenate multiple args after --error It should fix error dialogs on Windows since it decomposes the arg string. --- rpcs3/main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index 1adb381725d3..5db3d7f7bca5 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -271,7 +271,16 @@ int main(int argc, char** argv) // Only run RPCS3 to display an error if (int err_pos = find_arg(arg_error, argc, argv)) { - report_fatal_error(argv[err_pos + 1]); + // Reconstruction of the error from multiple args + std::string error; + for (int i = err_pos + 1; i < argc; i++) + { + if (i > err_pos + 1) + error += ' '; + error += argv[i]; + } + + report_fatal_error(error); } const std::string lock_name = fs::get_cache_dir() + "RPCS3.buf"; From 92eeec39b71ad87a668cf58bf73026e4e51dd519 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 10 Mar 2020 22:58:59 +0300 Subject: [PATCH 2/3] Improve Stop Watchdog Make it less possible to interfere with the debugger. --- rpcs3/Emu/System.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index f6f303a2eb80..3b060298a297 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -1645,17 +1645,17 @@ void Emulator::Stop(bool restart) named_thread stop_watchdog("Stop Watchdog", [&]() { - const auto start = std::chrono::steady_clock::now(); - - while (thread_ctrl::state() != thread_state::aborting) + for (uint i = 0; thread_ctrl::state() != thread_state::aborting; i++) { - if (std::chrono::steady_clock::now() - start >= 5s) + // We don't need accurate timekeeping, using clocks may interfere with debugging + if (i >= 1000) { + // Total amount of waiting: about 5s report_fatal_error("Stopping emulator took too long." "\nSome thread has probably deadlocked. Aborting."); } - thread_ctrl::wait_for(100'000); + thread_ctrl::wait_for(5'000); } }); From 6bd96a4590aa2050cc53eff0867d6426a9d82732 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 10 Mar 2020 23:23:32 +0300 Subject: [PATCH 3/3] Fix thread_base::finalize (and emergency_exit, collaterally) Forgot to reset futex callback. Could cause crashes. --- Utilities/Thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 8d840f8ce953..a0efec6ead62 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1912,6 +1912,7 @@ bool thread_base::finalize(int) noexcept void thread_base::finalize() noexcept { + atomic_storage_futex::set_wait_callback([](const void*){ return true; }); g_tls_log_prefix = []() -> std::string { return {}; }; thread_ctrl::g_tls_this_thread = nullptr; } @@ -2091,7 +2092,6 @@ void thread_ctrl::emergency_exit(std::string_view reason) delete _this; } - // Do some not very useful cleanup thread_base::finalize(); #ifdef _WIN32