1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 12:42:41 +01:00

CPUThread.cpp: Fix an emulator crash on game exit

This commit is contained in:
Elad Ashkenazi 2023-05-22 18:02:00 +03:00 committed by Ivan
parent e29b81c444
commit 23c710cf53
2 changed files with 8 additions and 1 deletions

View File

@ -35,6 +35,7 @@ static thread_local u32 s_tls_thread_slot = -1;
static thread_local u64 s_tls_sctr = -1; static thread_local u64 s_tls_sctr = -1;
extern thread_local void(*g_tls_log_control)(const char* fmt, u64 progress); extern thread_local void(*g_tls_log_control)(const char* fmt, u64 progress);
extern thread_local std::string(*g_tls_log_prefix)();
template <> template <>
void fmt_class_string<cpu_flag>::format(std::string& out, u64 arg) void fmt_class_string<cpu_flag>::format(std::string& out, u64 arg)
@ -478,6 +479,8 @@ namespace cpu_counter
void cpu_thread::operator()() void cpu_thread::operator()()
{ {
const auto old_prefix = g_tls_log_prefix;
g_tls_this_thread = this; g_tls_this_thread = this;
if (g_cfg.core.thread_scheduler != thread_scheduler_mode::os) if (g_cfg.core.thread_scheduler != thread_scheduler_mode::os)
@ -545,6 +548,7 @@ void cpu_thread::operator()()
{ {
cpu_thread* _this = nullptr; cpu_thread* _this = nullptr;
std::string name; std::string name;
std::string(*log_prefix)() = nullptr;
void cleanup() void cleanup()
{ {
@ -571,6 +575,8 @@ void cpu_thread::operator()()
s_cpu_counter--; s_cpu_counter--;
g_tls_log_prefix = log_prefix;
g_tls_this_thread = nullptr; g_tls_this_thread = nullptr;
g_threads_deleted++; g_threads_deleted++;
@ -590,6 +596,7 @@ void cpu_thread::operator()()
cleanup._this = this; cleanup._this = this;
cleanup.name = thread_ctrl::get_name(); cleanup.name = thread_ctrl::get_name();
cleanup.log_prefix = old_prefix;
// Check thread status // Check thread status
while (!(state & cpu_flag::exit) && thread_ctrl::state() != thread_state::aborting) while (!(state & cpu_flag::exit) && thread_ctrl::state() != thread_state::aborting)

View File

@ -602,7 +602,7 @@ void kernel_explorer::update()
std::optional<std::scoped_lock<shared_mutex, shared_mutex>> lock_idm_lv2(std::in_place, id_manager::g_mutex, lv2_obj::g_mutex); std::optional<std::scoped_lock<shared_mutex, shared_mutex>> lock_idm_lv2(std::in_place, id_manager::g_mutex, lv2_obj::g_mutex);
// Postponed as much as possible for time accuracy // Postponed as much as possible for time accuracy
u64 current_time_storage = get_guest_system_time(); u64 current_time_storage = 0;
auto get_current_time = [&current_time_storage]() auto get_current_time = [&current_time_storage]()
{ {