[llvm] [pdb] Provide a better error message when overflowing the public/global symbol record stream (PR #140884)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 21 05:03:47 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Hans Wennborg (zmodem)
<details>
<summary>Changes</summary>
Before:
lld-link: error: Stream Error: The stream is too short to perform the requested operation.
lld-link: error: failed to write PDB file ./unit_tests.exe.pdb
After:
lld-link: error: the public (2127832912 bytes) and global (2200532960 bytes) symbols are too large to fit in a PDB file.
lld-link: error: failed to write PDB file ./unit_tests.exe.pdb
---
Full diff: https://github.com/llvm/llvm-project/pull/140884.diff
1 Files Affected:
- (modified) llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp (+7-2)
``````````diff
diff --git a/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
index c195754c0c679..0289a7543205a 100644
--- a/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
@@ -25,6 +25,7 @@
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
#include "llvm/Support/BinaryItemStream.h"
#include "llvm/Support/BinaryStreamWriter.h"
+#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Parallel.h"
#include "llvm/Support/TimeProfiler.h"
#include "llvm/Support/xxhash.h"
@@ -39,7 +40,7 @@ using namespace llvm::codeview;
// Helper class for building the public and global PDB hash table buckets.
struct llvm::pdb::GSIHashStreamBuilder {
// Sum of the size of all public or global records.
- uint32_t RecordByteSize = 0;
+ uint64_t RecordByteSize = 0;
std::vector<PSHashRecord> HashRecords;
@@ -319,7 +320,11 @@ Error GSIStreamBuilder::finalizeMsfLayout() {
return Idx.takeError();
PublicsStreamIndex = *Idx;
- uint32_t RecordBytes = PSH->RecordByteSize + GSH->RecordByteSize;
+ uint64_t RecordBytes = PSH->RecordByteSize + GSH->RecordByteSize;
+ if (RecordBytes > UINT32_MAX)
+ return make_error<StringError>(formatv("the public ({0} bytes) and global "
+ "({1} bytes) symbols are too large to fit in a PDB file.",
+ PSH->RecordByteSize, GSH->RecordByteSize), inconvertibleErrorCode());
Idx = Msf.addStream(RecordBytes);
if (!Idx)
``````````
</details>
https://github.com/llvm/llvm-project/pull/140884
More information about the llvm-commits
mailing list