[PATCH] D155176: [BTF] Fix BTFParserTest.cpp for unaligned access after D149058
Eduard Zingerman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 13 05:45:50 PDT 2023
eddyz87 created this revision.
Herald added a subscriber: pengfei.
Herald added a project: All.
luporl added a comment.
eddyz87 published this revision for review.
eddyz87 added reviewers: luporl, MaskRay.
eddyz87 added a subscriber: MaskRay.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
I've tested this patch and it also fixes unit tests for this ARM bot:
https://lab.llvm.org/buildbot/#/builders/245/builds/10973
eddyz87 added a comment.
Hi @luporl,
In D155176#4497053 <https://reviews.llvm.org/D155176#4497053>, @luporl wrote:
> I've tested this patch and it also fixes unit tests for this ARM bot:
> https://lab.llvm.org/buildbot/#/builders/245/builds/10973
Thank you for testing it, the pre-merge build also finished green. May I ask you to be a formal reviewer?
@MaskRay agreed with these changes here <https://reviews.llvm.org/D149058#4496161>.
Test bot reported an issue with unit tests for D149058 <https://reviews.llvm.org/D149058> in [1]:
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from BTFParserTest
[ RUN ] BTFParserTest.simpleCorrectInput
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp:141:33:
runtime error: upcast of misaligned address 0x7facce60411f for type 'llvm::SmallString<0>', which requires 8 byte alignment
0x7facce60411f: note: pointer points here
64 00 00 00 37 41 60 ce ac 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp:141:33
The issue is caused by attribute "packed" used for too many things:
#pragma pack(push, 1)
struct MockData1 {
struct B {
...
} BTF;
struct E {
...
} Ext;
int BTFSectionLen = sizeof(BTF);
int ExtSectionLen = sizeof(Ext);
SmallString<0> Storage;
std::unique_ptr<ObjectFile> Obj;
}
#pragma pack(pop)
Access to unaligned pointers in `Storage`/`Obj` causes unaligned
access errors.
To fix this #pragma directives are pushed invards to apply only to `B`
and `E` definitions.
[1] https://lab.llvm.org/buildbot/#/builders/5/builds/35040
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155176
Files:
llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp
Index: llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp
===================================================================
--- llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp
+++ llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp
@@ -45,11 +45,11 @@
// modified before a call to `makeObj()` to test parser with invalid
// input, etc.
+struct MockData1 {
// Use "pragma pack" to model .BTF & .BTF.ext sections content using
// 'struct' objects. This pragma is supported by CLANG, GCC & MSVC,
// which matters for LLVM CI.
#pragma pack(push, 1)
-struct MockData1 {
struct B {
BTF::Header Header = {};
// no types
@@ -100,6 +100,7 @@
Header.LineInfoLen = sizeof(Lines);
}
} Ext;
+#pragma pack(pop)
int BTFSectionLen = sizeof(BTF);
int ExtSectionLen = sizeof(Ext);
@@ -148,7 +149,6 @@
return *Obj.get();
}
};
-#pragma pack(pop)
TEST(BTFParserTest, simpleCorrectInput) {
BTFParser BTF;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155176.539946.patch
Type: text/x-patch
Size: 934 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230713/4d8fb79f/attachment.bin>
More information about the llvm-commits
mailing list