mirror of
https://github.com/sockspls/badfish
synced 2025-05-02 17:49:35 +00:00
Fix crash in best_group() (#1891)
This pull request fixes a rare crashing bug on Windows inside our NUMA code, first reported by Dann Corbit in the following forum thread (thanks!): https://groups.google.com/forum/?fromgroups=#!topic/fishcooking/gA6aoMEuOwg The fix is to not use structure member beyond known size when iterating through 'SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX' structure. We note that the Microsoft API is guaranteed to provide us at least one element upon successful, and no element in the structure can have a zero size. No functional change.
This commit is contained in:
parent
ade87ff8d3
commit
0194da0d80
1 changed files with 2 additions and 1 deletions
|
@ -257,7 +257,7 @@ int best_group(size_t idx) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ptr->Size > 0 && byteOffset + ptr->Size <= returnLength)
|
while (byteOffset < returnLength)
|
||||||
{
|
{
|
||||||
if (ptr->Relationship == RelationNumaNode)
|
if (ptr->Relationship == RelationNumaNode)
|
||||||
nodes++;
|
nodes++;
|
||||||
|
@ -268,6 +268,7 @@ int best_group(size_t idx) {
|
||||||
threads += (ptr->Processor.Flags == LTP_PC_SMT) ? 2 : 1;
|
threads += (ptr->Processor.Flags == LTP_PC_SMT) ? 2 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(ptr->Size);
|
||||||
byteOffset += ptr->Size;
|
byteOffset += ptr->Size;
|
||||||
ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((char*)ptr) + ptr->Size);
|
ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((char*)ptr) + ptr->Size);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue