[llvm] 23cd70d - [PDB] Fix out-of-bounds acces when sorting GSI buckets
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 10 07:58:43 PDT 2020
Author: Alexandre Ganea
Date: 2020-07-10T10:55:27-04:00
New Revision: 23cd70d71c10dc0b31ac37a733349f9de2e9b84c
URL: https://github.com/llvm/llvm-project/commit/23cd70d71c10dc0b31ac37a733349f9de2e9b84c
DIFF: https://github.com/llvm/llvm-project/commit/23cd70d71c10dc0b31ac37a733349f9de2e9b84c.diff
LOG: [PDB] Fix out-of-bounds acces when sorting GSI buckets
When building in Debug on Windows-MSVC after b7402edce315, a lot of tests were failing because we were dereferencing an element past the end of HashRecords. This happened towards the end of the table, in unused slots.
Added:
Modified:
llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
index ce248f34762d..4e58489f1401 100644
--- a/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
@@ -232,8 +232,10 @@ void GSIHashStreamBuilder::finalizeBuckets(
// The algorithm used here corresponds to the function
// caseInsensitiveComparePchPchCchCch in the reference implementation.
parallelForEachN(0, IPHR_HASH, [&](size_t I) {
- auto B = &HashRecords[BucketStarts[I]];
- auto E = &HashRecords[BucketCursors[I]];
+ auto B = HashRecords.begin() + BucketStarts[I];
+ auto E = HashRecords.begin() + BucketCursors[I];
+ if (B == E)
+ return;
auto BucketCmp = [Records](const PSHashRecord &LHash,
const PSHashRecord &RHash) {
const BulkPublic &L = Records[uint32_t(LHash.Off)];
More information about the llvm-commits
mailing list