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

ASAN error in rclcpp_action test_goal_handle #1528

Closed
y-okumura-isp opened this issue Jan 26, 2021 · 0 comments · Fixed by #1529
Closed

ASAN error in rclcpp_action test_goal_handle #1528

y-okumura-isp opened this issue Jan 26, 2021 · 0 comments · Fixed by #1529

Comments

@y-okumura-isp
Copy link
Contributor

Bug report

Required Info:

  • Operating System:
    • Ubuntu 20.04
  • Installation type:
    • build
  • Version or commit hash:
  • DDS implementation:
    • FastDDS
  • Client library (if applicable):
    • rclcpp_action

Steps to reproduce issue

Build with ASAN and run test_server_goal_handle.
In my environment, I got the following error.

$ ./build-asan/rclcpp_action/test_server_goal_handle 
Running main() from /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/src/gtest_main.cc
[==========] Running 6 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 6 tests from TestServerGoalHandle
[ RUN      ] TestServerGoalHandle.construct_destruct
[       OK ] TestServerGoalHandle.construct_destruct (1 ms)
[ RUN      ] TestServerGoalHandle.cancel
[       OK ] TestServerGoalHandle.cancel (0 ms)
[ RUN      ] TestServerGoalHandle.abort
[       OK ] TestServerGoalHandle.abort (1 ms)
[ RUN      ] TestServerGoalHandle.succeed
[       OK ] TestServerGoalHandle.succeed (0 ms)
[ RUN      ] TestServerGoalHandle.execute
[       OK ] TestServerGoalHandle.execute (0 ms)
[ RUN      ] TestServerGoalHandle.rcl_action_goal_handle_get_status_error
[       OK ] TestServerGoalHandle.rcl_action_goal_handle_get_status_error (0 ms)
[----------] 6 tests from TestServerGoalHandle (2 ms total)

[----------] Global test environment tear-down
[==========] 6 tests from 1 test suite ran. (2 ms total)
[  PASSED  ] 6 tests.

=================================================================
==4185==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 432 byte(s) in 6 object(s) allocated from:
    #0 0x7f78696f1bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x7f78694a52e6 in __default_allocate /src/ros2_rolling_asan/src/ros2/rcutils/src/allocator.c:37
    #2 0x7f78694f5656 in rcl_action_goal_handle_init /src/ros2_rolling_asan/src/ros2/rcl/rcl_action/src/rcl_action/goal_handle.c:59
    #3 0x5559f88fe502 in TestServerGoalHandle::SetUp() (/src/ros2_rolling_asan/build-asan/rclcpp_action/test_server_goal_handle+0x36502)
    #4 0x5559f89981ab in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2433
    #5 0x5559f898820a in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2469
    #6 0x5559f892ffcd in testing::Test::Run() /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2503
    #7 0x5559f8931502 in testing::TestInfo::Run() /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2684
    #8 0x5559f8932214 in testing::TestSuite::Run() /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2816
    #9 0x5559f894ea9f in testing::internal::UnitTestImpl::RunAllTests() /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/./src/gtest.cc:5338
    #10 0x5559f899b6cf in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2433
    #11 0x5559f898ab43 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2469
    #12 0x5559f894b58f in testing::UnitTest::Run() /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/./src/gtest.cc:4925
    #13 0x5559f891c236 in RUN_ALL_TESTS() /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/include/gtest/gtest.h:2473
    #14 0x5559f891c111 in main /src/ros2_rolling_asan/install-asan/gtest_vendor/src/gtest_vendor/src/gtest_main.cc:45
    #15 0x7f78690ad0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

SUMMARY: AddressSanitizer: 432 byte(s) leaked in 6 allocation(s).

Expected behavior

No leak.

Actual behavior

See above.

Additional information

By trace #3, it looks that rcl_handle is not finalized by rcl_action_goal_handle_fini.
This looks a purely test code issue.

class TestServerGoalHandle : public ::testing::Test
{
  void SetUp()
  {
    std::shared_ptr<rcl_action_goal_handle_t> rcl_handle =
      std::make_shared<rcl_action_goal_handle_t>();

    // snip. zero_initialize and init rcl_handle but not fini
  }
}
y-okumura-isp added a commit to y-okumura-isp/rclcpp that referenced this issue Jan 26, 2021
Signed-off-by: y-okumura-isp <y-okumura@isp.co.jp>
clalancette pushed a commit that referenced this issue Jan 27, 2021
Signed-off-by: y-okumura-isp <y-okumura@isp.co.jp>
Karsten1987 pushed a commit that referenced this issue Mar 2, 2021
Signed-off-by: y-okumura-isp <y-okumura@isp.co.jp>
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

Successfully merging a pull request may close this issue.

1 participant