OSDN Git Service

[PDB] Don't ignore bucket 0 when writing the PDB string table.
authorZachary Turner <zturner@google.com>
Wed, 21 Mar 2018 22:23:59 +0000 (22:23 +0000)
committerZachary Turner <zturner@google.com>
Wed, 21 Mar 2018 22:23:59 +0000 (22:23 +0000)
commit1ea77ad5866e3ea503453634211b9baa442906e7
tree95281e90a50170dc989ee65df787edd52746c3e2
parent05d039d2025d6733de6f5c5ab9e3afeb605ef353
[PDB] Don't ignore bucket 0 when writing the PDB string table.

The hash table is a list of buckets, and the *value* stored in
the bucket cannot be 0 since that is reserved.  However, the code
here was incorrectly skipping over the 0'th bucket entirely.
The 0'th bucket is perfectly fine, just none of these buckets
can contain the value 0.

As a result, whenever there was a string where hash(S) % Size
was equal to 0, we would write the value in the next bucket
instead.  We never caught this in our tests due to *another*
bug, which is that we would iterate the entire list of buckets
looking for the value, only using the hash value as a starting
point.  However, the real algorithm stops when it finds 0 in
a bucket since it takes that to mean "the item is not in the
hash table".

The unit test is updated to carefully construct a set of hash
values that will cause one item to hash to 0 mod bucket count,
and the reader is also updated to return an error indicating that
the item is not found when it encounters a 0 bucket.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328162 91177308-0d34-0410-b5e6-96231b3b80d8
lib/DebugInfo/PDB/Native/PDBStringTable.cpp
lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp
unittests/DebugInfo/PDB/StringTableBuilderTest.cpp