diff --git a/external/Catch2 b/external/Catch2 index de7e863..bcfb10e 160000 --- a/external/Catch2 +++ b/external/Catch2 @@ -1 +1 @@ -Subproject commit de7e8630134f46e67a6b59269436f9cab94cd28e +Subproject commit bcfb10e498df3e2ed8f814b3e4b689b9a85608ab diff --git a/src/ke.cpp b/src/ke.cpp index 5109df9..cf26c71 100644 --- a/src/ke.cpp +++ b/src/ke.cpp @@ -157,6 +157,18 @@ usersim_set_current_thread_affinity(const GROUP_AFFINITY* new_affinity, GROUP_AF bool result; if (memcmp(new_affinity, &_usersim_group_affinity_cache, sizeof(*new_affinity)) == 0) { result = true; + } else if (new_affinity->Mask == 0) { + // Mask=0 means "no affinity override". We can't pass Mask=0 to + // SetThreadGroupAffinity (it requires at least one processor bit), + // so restore the thread to the process-default affinity instead. + DWORD_PTR process_mask = 0; + DWORD_PTR system_mask = 0; + if (GetProcessAffinityMask(GetCurrentProcess(), &process_mask, &system_mask) && process_mask != 0) { + GROUP_AFFINITY default_affinity = {}; + default_affinity.Mask = process_mask; + SetThreadGroupAffinity(GetCurrentThread(), &default_affinity, nullptr); + } + result = true; } else { result = SetThreadGroupAffinity(GetCurrentThread(), new_affinity, old_affinity); }