GetProcessGroupAffinity requires the memory for [out] PUSHORT GroupArray
to be overaligned. Is this (bug?) documented anywhere? Is this even a bug? The only mention I could find is here https://fossies.org/linux/fio/os/windows/cpu-affinity.c at line 236.
Reproduction:
#include <windows.h>
#include <iostream>
int main()
{
USHORT GroupCount = 1;
alignas(4) USHORT GroupArray[2];
auto status = GetProcessGroupAffinity(GetCurrentProcess(), &GroupCount, GroupArray);
auto a = GetLastError();
std::cout << a << ' ' << status << 'n';
status = GetProcessGroupAffinity(GetCurrentProcess(), &GroupCount, GroupArray + 1);
a = GetLastError();
std::cout << a << ' ' << status << 'n';
}
g++ a.cpp -static && ./a
prints
998 0
998 1
If anything, let this post serve as documentation for people searching for this issue (I intentionally worded the title this way to facilitate this, please don’t change it)