[PATCH] D98788: [lld-link] emit an error when writing a PDB > 4 GiB

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 17 08:59:15 PDT 2021


thakis created this revision.
thakis added a reviewer: rnk.
Herald added a subscriber: hiraditya.
thakis requested review of this revision.
Herald added a project: LLVM.

Maybe there's a way to make them work, but until I've investigated
if tools can consume large PDBs, erroring out is better than slowly
and silently consuming all available ram due to internal invariants
being violated.

(Patch to make writing larger files work at
https://bugs.chromium.org/p/chromium/issues/detail?id=1179085#c25
but I haven't had time to check if windbg & co can consume these
large PDBs. llvm-pdbutil can't, but we can fix that one at least :) )


https://reviews.llvm.org/D98788

Files:
  llvm/lib/DebugInfo/MSF/MSFBuilder.cpp


Index: llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
===================================================================
--- llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
+++ llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
@@ -341,7 +341,17 @@
 
   Layout = std::move(*L);
 
-  uint64_t FileSize = Layout.SB->BlockSize * Layout.SB->NumBlocks;
+  uint64_t FileSize = uint64_t(Layout.SB->BlockSize) * Layout.SB->NumBlocks;
+  if (FileSize > UINT32_MAX) {
+    // FIXME: Changing the BinaryStream classes to use 64-bit numbers lets
+    // us create PDBs larger than 4 GiB successfully. The file format is
+    // block-based and as long as each stream is small enough, PDBs larger than
+    // 4 GiB might work. Check if tools can handle these large PDBs, and if so
+    // add support for writing them.
+    return make_error<MSFError>(msf_error_code::invalid_format,
+                                "Output larger than 4 GiB");
+  }
+
   auto OutFileOrError = FileOutputBuffer::create(Path, FileSize);
   if (auto EC = OutFileOrError.takeError())
     return std::move(EC);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98788.331283.patch
Type: text/x-patch
Size: 1049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210317/b78e1ab9/attachment.bin>


More information about the llvm-commits mailing list