summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2019-09-25 17:58:41 +0800
committerLei YU <mine260309@gmail.com>2020-01-15 14:57:54 +0800
commit199b3b1299ff66b9ea7e0fadb66d5338087eee1a (patch)
tree6fd4255afcd542b7450818a067cd3d10af2d9b2d
parentd35c85239a85a101e866a7bd60aff4f40bf77401 (diff)
downloadsdbusplus-199b3b1299ff66b9ea7e0fadb66d5338087eee1a.tar.gz
sdbusplus-199b3b1299ff66b9ea7e0fadb66d5338087eee1a.zip
Add valgrind suppression
On latest OpenBMC, sdbusplus CI fails due to valgrind check like below on ppc64le systems: ==5290== Syscall param epoll_ctl(event) points to uninitialised byte(s) ==5290== at 0x4F2FB08: epoll_ctl (syscall-template.S:79) ==5290== by 0x493A8F7: UnknownInlinedFun (sd-event.c:961) ==5290== by 0x493A8F7: sd_event_add_time (sd-event.c:1019) ==5290== by 0x190BB3: phosphor::Timer::Timer(sd_event*, std::function<void ()>) (timer.hpp:62) ==5290== by 0x192B93: TimerTest::TimerTest() (timer.cpp:25) ==5290== by 0x193A13: TimerTest_timerExpiresAfter2seconds_Test::TimerTest_timerExpiresAfter2seconds_Test() (timer.cpp:85) ==5290== by 0x19E11F: testing::internal::TestFactoryImpl<TimerTest_timerExpiresAfter2seconds_Test>::CreateTest() (gtest-internal.h:472) ==5290== by 0x4A52D3B: HandleSehExceptionsInMethodIfSupported<testing::internal::TestFactoryBase, testing::Test*> (gtest.cc:2447) ==5290== by 0x4A52D3B: testing::Test* testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::TestFactoryBase, testing::Test*>(testing::internal::TestFactoryBase*, testing::Test * (testing::internal::TestFactoryBase::*)(), char const*) (gtest.cc:2483) ==5290== by 0x4A40BCB: Run (gtest.cc:2693) ==5290== by 0x4A40BCB: testing::TestInfo::Run() (gtest.cc:2676) ==5290== by 0x4A40DC3: Run (gtest.cc:2825) ==5290== by 0x4A40DC3: testing::TestCase::Run() (gtest.cc:2810) ==5290== by 0x4A414AF: testing::internal::UnitTestImpl::RunAllTests() (gtest.cc:5216) ==5290== by 0x4A5329B: HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (gtest.cc:2447) ==5290== by 0x4A5329B: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl:: *)(), char const*) (gtest.cc:2483) ==5290== by 0x4A416AF: testing::UnitTest::Run() (gtest.cc:4824) ==5290== by 0x4A90917: RUN_ALL_TESTS (gtest.h:2370) ==5290== by 0x4A90917: main (gmock_main.cc:69) ==5290== Address 0x1fff00eafc is on thread 1's stack ==5290== in frame #0, created by epoll_ctl (syscall-template.S:78) ==5290== The root cause is: 1. GCC has a bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77992, that the padding bytes are not initialized. 2. In systemd, the code in [libsystemd/sd-event/sd-event.c][1] using epoll_event hit the above bug: typedef union epoll_data { void *ptr; int fd; uint32_t u32; uint64_t u64; } epoll_data_t; struct epoll_event { uint32_t events; /* Epoll events */ epoll_data_t data; /* User data variable */ } __EPOLL_PACKED; In glibc, on x86, `__EPOLL_PACKED` is defined as `__attribute__ ((__packed__))`[2], so it's packed and there are no internal padding bytes; On other architectures (e.g. ppc64le), __EPOLL_PACKED is not defined and thus there are 4 internal padding bytes between `events` and `data`, that are not initialized. 3. When epoll_ctl() is invoked, in [Linux kernel][3], it does a copy_from_user() to copy the whole struct into kernel space. That's why Valgrind reports "epoll_ctl(event) points to uninitialised byte(s)", only for non-x86 platforms. 4. The timer test in this repo invokes sd_event_add_time() and eventually hit the above code. The GCC bug is not resolved from 2016. The systemd code is actually correct. There is a [PR][4] sent to systemd trying to workaround the issue, and it is being discussed. Before GCC bug is resolved or systemd PR is accepted, suppress the valgrind error to make it pass the CI. [1]: https://github.com/systemd/systemd/blob/v242/src/libsystemd/sd-event/sd-event.c#L961 [2]: https://github.com/bminor/glibc/blob/f1a0eb5b6762b315517469da47735c51bde6f4ad/sysdeps/unix/sysv/linux/x86/bits/epoll.h#L29 [3]: https://github.com/torvalds/linux/blob/d1eef1c619749b2a57e514a3fa67d9a516ffa919/fs/eventpoll.c#L2095 [4]: https://github.com/systemd/systemd/pull/14353 Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: I3a29fd0e28e5c7b69037a7ef2ef9571f93d80df7
-rw-r--r--test/Makefile.am2
-rw-r--r--test/valgrind.supp8
2 files changed, 10 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 857f293..ab52758 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,4 +1,6 @@
@VALGRIND_CHECK_RULES@
+VALGRIND_SUPPRESSIONS_FILES = valgrind.supp
+
if WANT_LIBSDBUSPLUS
diff --git a/test/valgrind.supp b/test/valgrind.supp
new file mode 100644
index 0000000..8330303
--- /dev/null
+++ b/test/valgrind.supp
@@ -0,0 +1,8 @@
+{
+ <suppress_epoll_ctl>
+ Memcheck:Param
+ epoll_ctl(event)
+ fun:epoll_ctl
+ ...
+ fun:sd_event*
+}
OpenPOWER on IntegriCloud