[PATCH] D144385: [PDB] Error on too large stream directories
Hans Wennborg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 20 05:32:09 PST 2023
hans created this revision.
hans added reviewers: chrdavis, aganea.
Herald added a subscriber: hiraditya.
Herald added a project: All.
hans requested review of this revision.
Herald added a project: LLVM.
We hit this in Chromium builds where the PDB file was just under 4GB, but the stream directory was actually too large to be correctly represented.
`llvm-pdbutil` would error about this in `llvm::msf::validateSuperBlock`, but lld should not write such PDB files in the first place.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144385
Files:
llvm/include/llvm/DebugInfo/MSF/MSFError.h
llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
llvm/lib/DebugInfo/MSF/MSFError.cpp
Index: llvm/lib/DebugInfo/MSF/MSFError.cpp
===================================================================
--- llvm/lib/DebugInfo/MSF/MSFError.cpp
+++ llvm/lib/DebugInfo/MSF/MSFError.cpp
@@ -43,6 +43,8 @@
return "The data is in an unexpected format.";
case msf_error_code::block_in_use:
return "The block is already in use.";
+ case msf_error_code::stream_directory_overflow:
+ return "PDB Stream directory too large.";
}
llvm_unreachable("Unrecognized msf_error_code");
}
Index: llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
===================================================================
--- llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
+++ llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
@@ -364,6 +364,18 @@
FileSize, Layout.SB->BlockSize));
}
+ uint64_t NumDirectoryBlocks =
+ bytesToBlocks(Layout.SB->NumDirectoryBytes, Layout.SB->BlockSize);
+ uint64_t DirectoryBlockMapSize =
+ NumDirectoryBlocks * sizeof(support::ulittle32_t);
+ if (DirectoryBlockMapSize > Layout.SB->BlockSize) {
+ return make_error<MSFError>(msf_error_code::stream_directory_overflow,
+ formatv("The directory block map ({0} bytes) "
+ "doesn't fit in a block ({1} bytes)",
+ DirectoryBlockMapSize,
+ Layout.SB->BlockSize));
+ }
+
auto OutFileOrError = FileOutputBuffer::create(Path, FileSize);
if (auto EC = OutFileOrError.takeError())
return std::move(EC);
Index: llvm/include/llvm/DebugInfo/MSF/MSFError.h
===================================================================
--- llvm/include/llvm/DebugInfo/MSF/MSFError.h
+++ llvm/include/llvm/DebugInfo/MSF/MSFError.h
@@ -23,7 +23,8 @@
not_writable,
no_stream,
invalid_format,
- block_in_use
+ block_in_use,
+ stream_directory_overflow
};
} // namespace msf
} // namespace llvm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144385.498805.patch
Type: text/x-patch
Size: 1946 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230220/1feb4dba/attachment.bin>
More information about the llvm-commits
mailing list