-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
to-jiraUse to create a placeholder Jira issue in Jira APIs ProjectUse to create a placeholder Jira issue in Jira APIs Project
Description
Raised from #1279 (comment)
The good news is that
asanhas already spotted some issues:==37969==ERROR: LeakSanitizer: detected memory leaks Direct leak of 48 byte(s) in 2 object(s) allocated from: #0 0x7fda668fe548 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:95 #1 0x5564bcfc6901 in hazelcast::client::test::thread_pool::ThreadPoolTest_testEqualThreadAndJobs_Test::TestBody() /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/hazelcast/test/src/HazelcastTests8.cpp:2733 #2 0x5564be3078f3 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/googletest-src/googletest/src/gtest.cc:2433 #3 0x5564be2f8fa0 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/googletest-src/googletest/src/gtest.cc:2469 #4 0x5564be2a3afd in testing::Test::Run() /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/googletest-src/googletest/src/gtest.cc:2508 #5 0x5564be2a4fd0 in testing::TestInfo::Run() /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/googletest-src/googletest/src/gtest.cc:2684 #6 0x5564be2a5d2b in testing::TestSuite::Run() /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/googletest-src/googletest/src/gtest.cc:2816 #7 0x5564be2c28ef in testing::internal::UnitTestImpl::RunAllTests() /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/googletest-src/googletest/src/gtest.cc:5338 #8 0x5564be30aca8 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/googletest-src/googletest/src/gtest.cc:2433 #9 0x5564be2fb991 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/googletest-src/googletest/src/gtest.cc:2469 #10 0x5564be2bf3ac in testing::UnitTest::Run() /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/googletest-src/googletest/src/gtest.cc:4925 #11 0x5564be3291f0 in RUN_ALL_TESTS() /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/googletest-src/googletest/include/gtest/gtest.h:2473 #12 0x5564be32913c in main /home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/googletest-src/googletest/src/gtest_main.cc:45 #13 0x7fda6602a1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 #14 0x7fda6602a28a in __libc_start_main_impl ../csu/libc-start.c:360 #15 0x5564bc4f0e14 in _start (/home/runner/work/hazelcast-cpp-client/hazelcast-cpp-client/build/hazelcast/test/src/client_test+0x3e2e14) (BuildId: 1ae11315358a2aa750dab7fc7ac35241e01a2005
We create a new client via a future, but the future is never cleaned up.
| client = new hazelcast_client{ new_client(std::move(config)).get() }; |
Context:
hazelcast-cpp-client/hazelcast/test/src/HazelcastTests8.cpp
Lines 2683 to 2762 in 02614f2
| namespace thread_pool { | |
| class ThreadPoolTest | |
| : public ClientTest | |
| , public testing::WithParamInterface<int32_t> | |
| { | |
| protected: | |
| struct ThreadState | |
| { | |
| explicit ThreadState(int latch_count) | |
| : latch1(latch_count) | |
| { | |
| } | |
| boost::latch latch1; | |
| std::set<boost::thread::id> thread_ids; | |
| }; | |
| protected: | |
| static void SetUpTestCase() | |
| { | |
| instance = new HazelcastServer(default_server_factory()); | |
| } | |
| static void TearDownTestCase() | |
| { | |
| delete client; | |
| delete instance; | |
| client = nullptr; | |
| instance = nullptr; | |
| } | |
| static HazelcastServer* instance; | |
| static hazelcast_client* client; | |
| }; | |
| HazelcastServer* ThreadPoolTest::instance = nullptr; | |
| hazelcast_client* ThreadPoolTest::client = nullptr; | |
| TEST_P(ThreadPoolTest, testEqualThreadAndJobs) | |
| { | |
| int32_t num_of_thread = 5; | |
| int32_t num_of_jobs = GetParam(); | |
| client_config config; | |
| config.set_executor_pool_size(num_of_thread); | |
| if (client != nullptr) { | |
| client->shutdown().get(); | |
| } | |
| client = new hazelcast_client{ new_client(std::move(config)).get() }; | |
| spi::ClientContext ctx(*client); | |
| auto state = std::make_shared<ThreadState>(num_of_jobs); | |
| std::mutex mutex_for_thread_id; | |
| uint32_t expected_thread_num = std::min(num_of_jobs, num_of_thread); | |
| boost::barrier sync_barrier(expected_thread_num); | |
| ASSERT_EQ(0, state->thread_ids.size()); | |
| for (int i = 0; i < num_of_jobs; i++) { | |
| ctx.get_client_execution_service().get_user_executor().submit( | |
| [state, &mutex_for_thread_id, &sync_barrier]() { | |
| sync_barrier.count_down_and_wait(); | |
| auto curr_thread_id = boost::this_thread::get_id(); | |
| { | |
| std::lock_guard<std::mutex> lg(mutex_for_thread_id); | |
| state->thread_ids.insert(curr_thread_id); | |
| } | |
| state->latch1.count_down(); | |
| }); | |
| } | |
| ASSERT_OPEN_EVENTUALLY(state->latch1); | |
| ASSERT_EQ( expected_thread_num, state->thread_ids.size()); | |
| } | |
| INSTANTIATE_TEST_SUITE_P(ThreadPoolTestSuite, | |
| ThreadPoolTest, | |
| ::testing::Values(5, 10, 2)); | |
| } // namespace thread_pool |
Metadata
Metadata
Assignees
Labels
to-jiraUse to create a placeholder Jira issue in Jira APIs ProjectUse to create a placeholder Jira issue in Jira APIs Project