-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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
Conversation
…al symbol record stream 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
@llvm/pr-subscribers-platform-windows Author: Hans Wennborg (zmodem) ChangesBefore: lld-link: error: Stream Error: The stream is too short to perform the requested operation. After: lld-link: error: the public (2127832912 bytes) and global (2200532960 bytes) symbols are too large to fit in a PDB file. Full diff: https://github.com/llvm/llvm-project/pull/140884.diff 1 Files Affected:
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)
|
@llvm/pr-subscribers-debuginfo Author: Hans Wennborg (zmodem) ChangesBefore: lld-link: error: Stream Error: The stream is too short to perform the requested operation. After: lld-link: error: the public (2127832912 bytes) and global (2200532960 bytes) symbols are too large to fit in a PDB file. Full diff: https://github.com/llvm/llvm-project/pull/140884.diff 1 Files Affected:
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)
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Looks good, but I wonder if we should hint at any way to resolve the problem? I am not sure I would know what to do when this happen and end up on this Pull Request after some research :) |
uint64_t RecordBytes = PSH->RecordByteSize + GSH->RecordByteSize; | ||
if (RecordBytes > UINT32_MAX) | ||
return make_error<StringError>( | ||
formatv("the public ({0} bytes) and global ({1} bytes) " |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Done.
I don't think there's room for much info into the error message, but we can certainly put some notes here.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
uint64_t RecordBytes = PSH->RecordByteSize + GSH->RecordByteSize; | ||
if (RecordBytes > UINT32_MAX) | ||
return make_error<StringError>( | ||
formatv("the public ({0} bytes) and global ({1} bytes) " |
There was a problem hiding this comment.
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.
return make_error<StringError>( | ||
formatv("the public ({0} bytes) and global ({1} bytes) " | ||
"symbols are too large to fit in a PDB file; ", | ||
"the maximum total is 4294967295 bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe pass UINT32_MAX as a parameter to the formatter so we don't have to hardcode the decimal value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
return make_error<StringError>( | ||
formatv("the public ({0} bytes) and global ({1} bytes) " | ||
"symbols are too large to fit in a PDB file; " | ||
"the maximum total is {2} bytes.", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
…als record stream Follow-up to llvm/llvm-project#140884
…al symbol record stream (llvm#140884) 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; the maximum total is 4294967295 bytes. lld-link: error: failed to write PDB file ./unit_tests.exe.pdb
…stream Follow-up to llvm#140884
…al symbol record stream (llvm#140884) 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; the maximum total is 4294967295 bytes. lld-link: error: failed to write PDB file ./unit_tests.exe.pdb
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; the maximum total is 4294967295 bytes.
lld-link: error: failed to write PDB file ./unit_tests.exe.pdb