Skip to content
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

Testcases that use the sd_bus_add_object_vtable mock now fail in CI #97

Open
spinler opened this issue Jul 22, 2024 · 0 comments
Open

Comments

@spinler
Copy link
Contributor

spinler commented Jul 22, 2024

Ever since CI was updated to fail on a valgrind error, any testcase that uses that sd_bus_add_object_vtable mock fails with something like:

(from https://jenkins.openbmc.org/job/ci-repository/88451/console triggered by https://gerrit.openbmc.org/c/openbmc/phosphor-hwmon/+/72996)

6/6 fanpwm_unittest                 FAIL             1.83s   exit status 1
>>> MALLOC_PERTURB_=139 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 valgrind --error-exitcode=1 /data0/jenkins/workspace/ci-repository/openbmc/phosphor-hwmon/build/test/fanpwm_unittest
 ✀  
Listing only the last 100 lines from a long log.
==687==    by 0x513152A: std::ostream& std::ostream::_M_insert<void const*>(void const*) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.33)
==687==    by 0x147A5A: operator<< (ostream:293)
==687==    by 0x147A5A: void testing::internal::PointerPrinter::PrintValue<sd_bus_slot>(sd_bus_slot*, std::ostream*) (gtest-printers.h:197)
==687==    by 0x147A7D: void testing::internal::PrintWithFallback<sd_bus_slot*>(sd_bus_slot* const&, std::ostream*) (gtest-printers.h:336)
==687==    by 0x147A8F: void testing::internal::PrintTo<sd_bus_slot*>(sd_bus_slot* const&, std::ostream*) (gtest-printers.h:465)
==687==    by 0x147AD2: Print (gtest-printers.h:808)
==687==    by 0x147AD2: void testing::internal::PrintTupleTo<std::tuple<sd_bus_slot*>, 1ul>(std::tuple<sd_bus_slot*> const&, std::integral_constant<unsigned long, 1ul>, std::ostream*) (gtest-printers.h:764)
==687==    by 0x147B01: void testing::internal::PrintTo<sd_bus_slot*>(std::tuple<sd_bus_slot*> const&, std::ostream*) (gtest-printers.h:771)
==687==    by 0x147B24: Print (gtest-printers.h:808)
==687==    by 0x147B24: void testing::internal::UniversalPrint<std::tuple<sd_bus_slot*> >(std::tuple<sd_bus_slot*> const&, std::ostream*) (gtest-printers.h:1112)
==687==    by 0x16868B: testing::internal::FunctionMocker<sd_bus_slot* (sd_bus_slot*)>::UntypedDescribeUninterestingCall(void const*, std::ostream*) const (gmock-spec-builders.h:1624)
==687==    by 0x16A705: testing::internal::FunctionMocker<sd_bus_slot* (sd_bus_slot*)>::InvokeWith(std::tuple<sd_bus_slot*>&&) (gmock-spec-builders.h:1828)
==687==    by 0x16AB40: Invoke (gmock-spec-builders.h:1548)
==687==    by 0x16AB40: sdbusplus::SdBusMock::sd_bus_slot_unref(sd_bus_slot*) (sdbus_mock.hpp:159)
==687== 
==687== Conditional jump or move depends on uninitialised value(s)
==687==    at 0x4E4AB47: ~unique_ptr (unique_ptr.h:403)
==687==    by 0x4E4AB47: ~slot (slot.hpp:43)
==687==    by 0x4E4AB47: sdbusplus::server::interface::interface::~interface() (interface.cpp:38)
==687==    by 0x137DAE: ~FanPwm (server.hpp:32)
==687==    by 0x137DAE: ~compose (object.hpp:181)
==687==    by 0x137DAE: sdbusplus::server::object::object<sdbusplus::server::xyz::openbmc_project::control::FanPwm>::~object() (object.hpp:95)
==687==    by 0x137EE3: hwmon::FanPwm::~FanPwm() (fan_pwm.hpp:18)
==687==    by 0x1205A6: FanPwmTest_BasicConstructorNotDeferredTest_Test::TestBody() (fanpwm_unittest.cpp:107)
==687==    by 0x4FA250E: HandleSehExceptionsInMethodIfSupported<testing::Test, void> (gtest.cc:2612)
==687==    by 0x4FA250E: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2648)
==687==    by 0x4F90B05: Run (gtest.cc:2687)
==687==    by 0x4F90B05: testing::Test::Run() (gtest.cc:2677)
==687==    by 0x4F90CC4: testing::TestInfo::Run() (gtest.cc:2836)
==687==    by 0x4F90EAE: Run (gtest.cc:3015)
==687==    by 0x4F90EAE: testing::TestSuite::Run() (gtest.cc:2968)
==687==    by 0x4F9718B: testing::internal::UnitTestImpl::RunAllTests() (gtest.cc:5920)
==687==    by 0x4FA2BE6: HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (gtest.cc:2612)
==687==    by 0x4FA2BE6: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2648)
==687==    by 0x4F910A7: testing::UnitTest::Run() (gtest.cc:5484)
==687==    by 0x4F3E103: RUN_ALL_TESTS (gtest.h:2317)
==687==    by 0x4F3E103: main (gtest_main.cc:64)
==687== 
==687== Conditional jump or move depends on uninitialised value(s)
==687==    at 0x4E4AB47: ~unique_ptr (unique_ptr.h:403)
==687==    by 0x4E4AB47: ~slot (slot.hpp:43)
==687==    by 0x4E4AB47: sdbusplus::server::interface::interface::~interface() (interface.cpp:38)
==687==    by 0x137DAE: ~FanPwm (server.hpp:32)
==687==    by 0x137DAE: ~compose (object.hpp:181)
==687==    by 0x137DAE: sdbusplus::server::object::object<sdbusplus::server::xyz::openbmc_project::control::FanPwm>::~object() (object.hpp:95)
==687==    by 0x137EE3: hwmon::FanPwm::~FanPwm() (fan_pwm.hpp:18)
==687==    by 0x11FC77: FanPwmTest_WriteTargetValue_Test::TestBody() (fanpwm_unittest.cpp:150)
==687==    by 0x4FA250E: HandleSehExceptionsInMethodIfSupported<testing::Test, void> (gtest.cc:2612)
==687==    by 0x4FA250E: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2648)
==687==    by 0x4F90B05: Run (gtest.cc:2687)
==687==    by 0x4F90B05: testing::Test::Run() (gtest.cc:2677)
==687==    by 0x4F90CC4: testing::TestInfo::Run() (gtest.cc:2836)
==687==    by 0x4F90EAE: Run (gtest.cc:3015)
==687==    by 0x4F90EAE: testing::TestSuite::Run() (gtest.cc:2968)
==687==    by 0x4F9718B: testing::internal::UnitTestImpl::RunAllTests() (gtest.cc:5920)
==687==    by 0x4FA2BE6: HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (gtest.cc:2612)
==687==    by 0x4FA2BE6: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2648)
==687==    by 0x4F910A7: testing::UnitTest::Run() (gtest.cc:5484)
==687==    by 0x4F3E103: RUN_ALL_TESTS (gtest.h:2317)
==687==    by 0x4F3E103: main (gtest_main.cc:64)
==687== 
==687== Conditional jump or move depends on uninitialised value(s)
==687==    at 0x4E4AB47: ~unique_ptr (unique_ptr.h:403)
==687==    by 0x4E4AB47: ~slot (slot.hpp:43)
==687==    by 0x4E4AB47: sdbusplus::server::interface::interface::~interface() (interface.cpp:38)
==687==    by 0x137DAE: ~FanPwm (server.hpp:32)
==687==    by 0x137DAE: ~compose (object.hpp:181)
==687==    by 0x137DAE: sdbusplus::server::object::object<sdbusplus::server::xyz::openbmc_project::control::FanPwm>::~object() (object.hpp:95)
==687==    by 0x137EE3: hwmon::FanPwm::~FanPwm() (fan_pwm.hpp:18)
==687==    by 0x11F3D8: FanPwmTest_WriteTargetValueNoUpdate_Test::TestBody() (fanpwm_unittest.cpp:176)
==687==    by 0x4FA250E: HandleSehExceptionsInMethodIfSupported<testing::Test, void> (gtest.cc:2612)
==687==    by 0x4FA250E: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2648)
==687==    by 0x4F90B05: Run (gtest.cc:2687)
==687==    by 0x4F90B05: testing::Test::Run() (gtest.cc:2677)
==687==    by 0x4F90CC4: testing::TestInfo::Run() (gtest.cc:2836)
==687==    by 0x4F90EAE: Run (gtest.cc:3015)
==687==    by 0x4F90EAE: testing::TestSuite::Run() (gtest.cc:2968)
==687==    by 0x4F9718B: testing::internal::UnitTestImpl::RunAllTests() (gtest.cc:5920)
==687==    by 0x4FA2BE6: HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (gtest.cc:2612)
==687==    by 0x4FA2BE6: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2648)
==687==    by 0x4F910A7: testing::UnitTest::Run() (gtest.cc:5484)
==687==    by 0x4F3E103: RUN_ALL_TESTS (gtest.h:2317)
==687==    by 0x4F3E103: main (gtest_main.cc:64)
==687== 
==687== 
==687== HEAP SUMMARY:
==687==     in use at exit: 56 bytes in 1 blocks
==687==   total heap usage: 1,209 allocs, 1,208 frees, 218,730 bytes allocated
==687== 
==687== LEAK SUMMARY:
==687==    definitely lost: 0 bytes in 0 blocks
==687==    indirectly lost: 0 bytes in 0 blocks
==687==      possibly lost: 0 bytes in 0 blocks
==687==    still reachable: 56 bytes in 1 blocks
==687==         suppressed: 0 bytes in 0 blocks
==687== Rerun with --leak-check=full to see details of leaked memory
==687== 
==687== Use --track-origins=yes to see where uninitialised values come from
==687== For lists of detected and suppressed errors, rerun with: -s
==687== ERROR SUMMARY: 52 errors from 8 contexts (suppressed: 0 from 0)



Summary of Failures:

6/6 fanpwm_unittest          FAIL             1.83s   exit status 1

Ok:                 5   
Expected Fail:      0   
Fail:               1   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0   

Full log written to /data0/jenkins/workspace/ci-repository/openbmc/phosphor-hwmon/build/meson-logs/testlog-valgrind.txt
Traceback (most recent call last):
  File "/data0/jenkins/workspace/ci-repository/openbmc/openbmc-build-scripts/scripts/unit-test.py", line 1034, in _maybe_valgrind
    check_call_cmd(
  File "/data0/jenkins/workspace/ci-repository/openbmc/openbmc-build-scripts/scripts/unit-test.py", line 238, in check_call_cmd
    check_call(cmd, **kwargs)
  File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('meson', 'test', '-t', '10', '-C', 'build', '--print-errorlogs', '--wrapper', 'valgrind --error-exitcode=1')' returned non-zero exit status 1.

I tried to track down what was wrong and eventually gave up.

For phosphor-hwmon, I think I'm just going to remove the call to it because it's pretty much just testing sdbusplus at that point and not hwmon code anyway.

geissonator pushed a commit to openbmc/phosphor-hwmon that referenced this issue Jul 29, 2024
For some reason, having an expect on the sdbusplus mock
sd_bus_add_object_vtable causes valgrind to fail in CI with errors such
as:

```
==729843== Conditional jump or move depends on uninitialized value(s)
==729843==    at 0x5CB89AB: std::unique_ptr<sd_bus_slot, sdbusplus::slot::details::SlotDeleter>::~unique_ptr() (unique_ptr.h:403)
==729843==    by 0x5CB8665: sdbusplus::slot::slot::~slot() (slot.hpp:43)
==729843==    by 0x5CC3CC9: sdbusplus::server::interface::interface::~interface() (interface.cpp:38)
==729843==    by 0x13189B: sdbusplus::server::xyz::openbmc_project::control::FanPwm::~FanPwm() (server.hpp:32)
==729843==    by 0x13E267: sdbusplus::server::object::details::compose<sdbusplus::server::xyz::openbmc_project::control::FanPwm>::~compose() (object.hpp:181)
==729843==    by 0x13E4BC: sdbusplus::server::object::object<sdbusplus::server::xyz::openbmc_project::control::FanPwm>::~object() (object.hpp:95)
==729843==    by 0x13C5C9: hwmon::FanPwm::~FanPwm() (fan_pwm.hpp:18)
==729843==    by 0x12C0D1: FanPwmTest_BasicConstructorDeferredTest_Test::TestBody() (fanpwm_unittest.cpp:76)
==729843==    by 0x5E089FC: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2638)
==729843==    by 0x5DFE67A: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2674)
==729843==    by 0x5DD3BA3: testing::Test::Run() (gtest.cc:2713)
==729843==    by 0x5DD4661: testing::TestInfo::Run() (gtest.cc:2859)
```

There are 4 more stanzas of similar 'Conditional jump or move...'
errors.  None of these show up without the vtable expect.

Other repositories that use this same expect also fail.

I opened sdbusplus issue openbmc/sdbusplus#97 for the problem.  I spent
time looking into it, and did not figure anything out.

This commit just removes the call to it because in these testcases the
FanPwm object, which is just derived from the sdbuplus interface object,
is simply created on the stack:

```
hwmon::FanPwm f(...);
```

The unit tests aren't actually testing any code that conditionally
creates a FanPwm interface on D-Bus, so checking that it happens isn't
that useful and seems to more just be testing sdbusplus.

Change-Id: Idf2df085bf909af1ad94ba06863c4605831a3824
Signed-off-by: Matt Spinler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant