mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 11:43:56 +00:00
Fix exception when NtTerminateThread is called on the active thread. (#480)
Fixes a bug where `perform_context_switch_work` method erases the thread from the threads list and call its destructor but doesn't invalidate the `active_thread` property causing the following switch_to_thread call to call `active_thread->save(emu);` when `active_thread` is already destroyed and thus throws an exception when assigning to `last_registers`.
This commit is contained in:
@@ -52,6 +52,7 @@ namespace
|
||||
void perform_context_switch_work(windows_emulator& win_emu)
|
||||
{
|
||||
auto& threads = win_emu.process.threads;
|
||||
auto*& active = win_emu.process.active_thread;
|
||||
|
||||
for (auto it = threads.begin(); it != threads.end();)
|
||||
{
|
||||
@@ -61,6 +62,11 @@ namespace
|
||||
continue;
|
||||
}
|
||||
|
||||
if (active == &it->second)
|
||||
{
|
||||
active = nullptr;
|
||||
}
|
||||
|
||||
const auto [new_it, deleted] = threads.erase(it);
|
||||
if (!deleted)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user