xuzhenbao opened a new issue #394:
URL: https://github.com/apache/celix/issues/394


   Some memory leaks were reported in my test case. Here is my test case .
   ~~~C
   //json_rpc_tests.cpp
   
   int addFailed(void*, double , double , double *) {
       return -1;
   }
   
   void callFailedTestPreAllocated(void) {
       dyn_interface_type *intf = nullptr;
       FILE *desc = fopen("descriptors/example1.descriptor", "r");
       ASSERT_TRUE(desc != nullptr);
       int rc = dynInterface_parse(desc, &intf);
       ASSERT_EQ(0, rc);
       fclose(desc);
   
       char *result = nullptr;
       tst_serv serv {nullptr, addFailed, nullptr, nullptr, nullptr};
   
       rc = jsonRpc_call(intf, &serv, R"({"m":"add(DD)D", "a": [1.0,2.0]})", 
&result);
       ASSERT_EQ(0, rc);
   
       free(result);
       dynInterface_destroy(intf);
   }
   
   TEST_F(JsonRpcTests, callPreFailed) {
       callFailedTestPreAllocated();
   }
   ~~~
   
   The following is the test report.
   
   ~~~shell
   ==8131==ERROR: LeakSanitizer: detected memory leaks
   
   Direct leak of 8 byte(s) in 1 object(s) allocated from:
       #0 0x7fd762d1ed28 in __interceptor_calloc 
(/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
       #1 0x7fd762a3294a in jsonRpc_call 
/mnt/e/linux/code/celix-master/libs/dfi/src/json_rpc.c:120
       #2 0x7fd7640b7e30 in callFailedTestPreAllocated 
/mnt/e/linux/code/celix-master/libs/dfi/gtest/src/json_rpc_tests.cpp:220
       #3 0x7fd7640c06bc in JsonRpcTests_callPreFailed_Test::TestBody() 
/mnt/e/linux/code/celix-master/libs/dfi/gtest/src/json_rpc_tests.cpp:454
       #4 0x7fd76411d2e1 in void 
testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, 
void>(testing::Test*, void (testing::Test::*)(), char const*) 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2607
       #5 0x7fd764116192 in void 
testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, 
void>(testing::Test*, void (testing::Test::*)(), char const*) 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2643
       #6 0x7fd7640ece7d in testing::Test::Run() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2682
       #7 0x7fd7640ed85b in testing::TestInfo::Run() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2861
       #8 0x7fd7640ee10d in testing::TestSuite::Run() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:3015
       #9 0x7fd7640fd1c1 in testing::internal::UnitTestImpl::RunAllTests() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:5855
       #10 0x7fd76411e514 in bool 
testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
 bool>(testing::internal::UnitTestImpl*, bool 
(testing::internal::UnitTestImpl::*)(), char const*) 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2607
       #11 0x7fd76411714c in bool 
testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
 bool>(testing::internal::UnitTestImpl*, bool 
(testing::internal::UnitTestImpl::*)(), char const*) 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2643
       #12 0x7fd7640fb9dd in testing::UnitTest::Run() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:5438
       #13 0x7fd76412f668 in RUN_ALL_TESTS() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/include/gtest/gtest.h:2490
       #14 0x7fd76412f5f7 in main 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest_main.cc:52
       #15 0x7fd761281b96 in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
   
   Indirect leak of 8 byte(s) in 1 object(s) allocated from:
       #0 0x7fd762d1ed28 in __interceptor_calloc 
(/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
       #1 0x7fd762a2606a in dynType_alloc 
/mnt/e/linux/code/celix-master/libs/dfi/src/dyn_type.c:579
       #2 0x7fd762a32999 in jsonRpc_call 
/mnt/e/linux/code/celix-master/libs/dfi/src/json_rpc.c:124
       #3 0x7fd7640b7e30 in callFailedTestPreAllocated 
/mnt/e/linux/code/celix-master/libs/dfi/gtest/src/json_rpc_tests.cpp:220
       #4 0x7fd7640c06bc in JsonRpcTests_callPreFailed_Test::TestBody() 
/mnt/e/linux/code/celix-master/libs/dfi/gtest/src/json_rpc_tests.cpp:454
       #5 0x7fd76411d2e1 in void 
testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, 
void>(testing::Test*, void (testing::Test::*)(), char const*) 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2607
       #6 0x7fd764116192 in void 
testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, 
void>(testing::Test*, void (testing::Test::*)(), char const*) 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2643
       #7 0x7fd7640ece7d in testing::Test::Run() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2682
       #8 0x7fd7640ed85b in testing::TestInfo::Run() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2861
       #9 0x7fd7640ee10d in testing::TestSuite::Run() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:3015
       #10 0x7fd7640fd1c1 in testing::internal::UnitTestImpl::RunAllTests() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:5855
       #11 0x7fd76411e514 in bool 
testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
 bool>(testing::internal::UnitTestImpl*, bool 
(testing::internal::UnitTestImpl::*)(), char const*) 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2607
       #12 0x7fd76411714c in bool 
testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
 bool>(testing::internal::UnitTestImpl*, bool 
(testing::internal::UnitTestImpl::*)(), char const*) 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:2643
       #13 0x7fd7640fb9dd in testing::UnitTest::Run() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest.cc:5438
       #14 0x7fd76412f668 in RUN_ALL_TESTS() 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/include/gtest/gtest.h:2490
       #15 0x7fd76412f5f7 in main 
/mnt/e/linux/code/celix-master/build/_deps/googletest-src/googletest/src/gtest_main.cc:52
       #16 0x7fd761281b96 in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
   
   SUMMARY: AddressSanitizer: 16 byte(s) leaked in 2 allocation(s).
   
   ~~~


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to