-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[YAML] Don't validate Fill::Size
after error
#123280
[YAML] Don't validate Fill::Size
after error
#123280
Conversation
@llvm/pr-subscribers-llvm-support @llvm/pr-subscribers-objectyaml Author: Vitaly Buka (vitalybuka) ChangesSize is required, so we don't know if it's in Triggers msan on llvm/test/tools/yaml2obj/ELF/custom-fill.yaml Full diff: https://github.com/llvm/llvm-project/pull/123280.diff 1 Files Affected:
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index e0e941cff94c52..1d52cdef79400f 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -1750,7 +1750,9 @@ void MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::mapping(
std::string MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::validate(
IO &io, std::unique_ptr<ELFYAML::Chunk> &C) {
if (const auto *F = dyn_cast<ELFYAML::Fill>(C.get())) {
- if (F->Pattern && F->Pattern->binary_size() != 0 && !F->Size)
+ // Can't check the `Size`, as it's required and may be left uninitialized by
+ // previous error.
+ if (!io.error() && F->Pattern && F->Pattern->binary_size() != 0 && !F->Size)
return "\"Size\" can't be 0 when \"Pattern\" is not empty";
return "";
}
|
Size is required, so we don't know if it's in uninitialized state after the previous error. Triggers msan on llvm/test/tools/yaml2obj/ELF/custom-fill.yaml Pull Request: #123280
7c9e807
to
0caa47f
Compare
487784c
to
e696bc4
Compare
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.
LGTM, but might want to get @MaskRay to give a thumbs up to, given he's made a comment.
4ddbe28
to
c6e72c4
Compare
0a895fd
to
c6e72c4
Compare
Size is required, so we don't know if it's in
uninitialized state after the previous error.
Triggers msan on llvm/test/tools/yaml2obj/ELF/custom-fill.yaml NOSIZE test.
We have
Fill
Section with Pattern, but no size. Before the fix it produced error:The same applies to
MachOYAML::Section
fieldscontent
andsize
.However
MachOYAML::Section
matches size first, so on error,content is not set anyway. Added error checking just in case.