[llvm] [pdb] Fix public symbol hashing in GSIHashStreamBuilder::finalizeBuckets (PR #190133)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 01:36:52 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: Hans Wennborg (zmodem)

<details>
<summary>Changes</summary>

BulkPublic.Name is not necessarily null terminated, so make sure not to hash past its actual length.

In practice it would often be null terminated due to padding at the end of the S_PUB32 symbol, but in the cases where it's not, we would compute the wrong hash here, put it in the wrong hash bucket, preventing debuggers from looking up the symbol by name, causing issues such as https://discourse.llvm.org/t/pdb-generated-by-lld-link-doesnt-point-to-correct-entry-point-when-debugged-using-visual-studio/90349

---
Full diff: https://github.com/llvm/llvm-project/pull/190133.diff


1 Files Affected:

- (modified) llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp (+2-1) 


``````````diff
diff --git a/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
index 0c4b9362a0f04..e3ffbcbd93ac3 100644
--- a/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
@@ -200,7 +200,8 @@ void GSIHashStreamBuilder::finalizeBuckets(
     uint32_t RecordZeroOffset, MutableArrayRef<BulkPublic> Records) {
   // Hash every name in parallel.
   parallelFor(0, Records.size(), [&](size_t I) {
-    Records[I].setBucketIdx(hashStringV1(Records[I].Name) % IPHR_HASH);
+    StringRef Name = StringRef(Records[I].Name, Records[I].NameLen);
+    Records[I].setBucketIdx(hashStringV1(Name) % IPHR_HASH);
   });
 
   // Count up the size of each bucket. Then, use an exclusive prefix sum to

``````````

</details>


https://github.com/llvm/llvm-project/pull/190133


More information about the llvm-commits mailing list