Skip to content

Commit

Permalink
[PDB] Fix out-of-bounds acces when sorting GSI buckets
Browse files Browse the repository at this point in the history
When building in Debug on Windows-MSVC after b7402ed, 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.
  • Loading branch information
aganea committed Jul 10, 2020
1 parent 5fea54b commit 23cd70d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand Down

0 comments on commit 23cd70d

Please sign in to comment.