Skip to content

[pdb] Provide a better error message when overflowing the public/global symbol record stream #140884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;

Expand Down Expand Up @@ -319,7 +320,14 @@ 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) "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also display what the maximum size is? It’s obvious for us, but not for regular users.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github shows some kind of syntax error, maybe you have local fixup changes that didn't get pushed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Done.

"symbols are too large to fit in a PDB file; "
"the maximum total is {2} bytes.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "The public and global symbols are too large" can be read as if this is about two symbols, the public symbol and the global symbol. Maybe just "The public symbols and global symbols"? "The public and global symbol tables?" (I think that suggestion, while not being ambiguous, is incorrect, but I'm not sure. If it is, we obviously shouldn't use it :P)

Sorry for the bikeshed; feel free to ignore if you're happy with this as-is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, going with "the public symbols and global symbols" in 6bb05ea

PSH->RecordByteSize, GSH->RecordByteSize, UINT32_MAX),
inconvertibleErrorCode());

Idx = Msf.addStream(RecordBytes);
if (!Idx)
Expand Down
Loading