You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/03/19 12:14:46 UTC

[GitHub] [nifi-minifi-cpp] martinzink opened a new pull request #1035: MINIFI-1354: Memory leaks in nanofi and its unittests

martinzink opened a new pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035


   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] martinzink commented on a change in pull request #1035: MINIFI-1354: Memory leaks in nanofi and its unittests

Posted by GitBox <gi...@apache.org>.
martinzink commented on a change in pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035#discussion_r597631623



##########
File path: nanofi/src/api/nanofi.cpp
##########
@@ -131,20 +131,26 @@ nifi_instance *create_instance_repo(const char *url, nifi_port *port, const char
   return instance;
 }
 
+nifi_instance * acquire_standalone_instance () {
+  if (standalone_instance == nullptr) {
+    nifi_port port;
+    auto port_str = utils::IdGenerator::getIdGenerator()->generate().to_string();
+    port.port_id = const_cast<char *>(port_str.c_str());
+    standalone_instance = create_instance("internal_standalone", &port);
+  }
+  return standalone_instance;
+}
+
 standalone_processor * create_processor(const char *name, nifi_instance * instance) {
   NULL_CHECK(nullptr, name);
   auto ptr = ExecutionPlan::createProcessor(name, name);
   if (!ptr) {
     return nullptr;
   }
-  if (instance == NULL) {
-    nifi_port port;
-    auto port_str = utils::IdGenerator::getIdGenerator()->generate().to_string();
-    port.port_id = const_cast<char*>(port_str.c_str());
-    instance = create_instance("internal_standalone", &port);
-  }
+  if (instance == nullptr)
+    instance = acquire_standalone_instance();
   auto flow = create_new_flow(instance);
-  std::shared_ptr<ExecutionPlan> plan(flow);
+  std::shared_ptr<ExecutionPlan> plan(flow, free_flow);

Review comment:
       This caused the mismatched malloc vs operator delete (which has undefined behavior)




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] martinzink commented on a change in pull request #1035: MINIFI-1354: Memory leaks in nanofi and its unittests

Posted by GitBox <gi...@apache.org>.
martinzink commented on a change in pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035#discussion_r603206890



##########
File path: nanofi/tests/CLogAggregatorTests.cpp
##########
@@ -31,18 +31,19 @@
 
 #include "CTestsBase.h"
 
-void test_lists_equal(token_list * tknlist, const std::vector<std::string>& sv) {
+void test_lists_equal(const token_list * tknlist, const std::vector<std::string>& sv) {
     REQUIRE(tknlist != NULL);
     if (sv.empty()) {

Review comment:
       good idea, changed it in [e010b24](https://github.com/apache/nifi-minifi-cpp/pull/1035/commits/e010b24559ee441d528884f70e05eb68aec08400)




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1035: MINIFI-1354: Memory leaks in nanofi and its unittests

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035#discussion_r603127503



##########
File path: nanofi/tests/CLogAggregatorTests.cpp
##########
@@ -31,18 +31,19 @@
 
 #include "CTestsBase.h"
 
-void test_lists_equal(token_list * tknlist, const std::vector<std::string>& sv) {
+void test_lists_equal(const token_list * tknlist, const std::vector<std::string>& sv) {
     REQUIRE(tknlist != NULL);
     if (sv.empty()) {

Review comment:
       the body of this function might be refactored to the following
   
   ```
       REQUIRE(tknlist != NULL);
       REQUIRE(tknlist->size == sv.size());
       token_node *node = tknlist->head;
       for (const auto& s : sv) {
         REQUIRE(node);
         REQUIRE(strcmp(s.c_str(), node->data) == 0);
         node = node->next;
       }
       REQUIRE(node == nullptr);
   ```




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on pull request #1035: MINIFI-1354: Memory leaks in nanofi and its unittests

Posted by GitBox <gi...@apache.org>.
lordgamez commented on pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035#issuecomment-806538615


   > > Looks good, thanks for the fix. My question is, that would it be possible to have an ASAN build in the CI and have the sanitizer checks there as well?
   > 
   > Yeah that would be ideal, unfortunetly there are still couple of issues we need to fix before that can be enabled. e.g. [MINIFICPP-839](https://issues.apache.org/jira/browse/MINIFICPP-839)
   
   Oh, thanks for the info, I thought only these issues were found by the sanitizer.


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1035: MINIFI-1354: Memory leaks in nanofi and its unittests

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035#discussion_r601302083



##########
File path: nanofi/src/api/nanofi.cpp
##########
@@ -131,20 +131,26 @@ nifi_instance *create_instance_repo(const char *url, nifi_port *port, const char
   return instance;
 }
 
+nifi_instance * acquire_standalone_instance () {
+  if (standalone_instance == nullptr) {
+    nifi_port port;
+    auto port_str = utils::IdGenerator::getIdGenerator()->generate().to_string();
+    port.port_id = const_cast<char *>(port_str.c_str());

Review comment:
       We could initialize the port here like
   ```
   nifi_port port{const_cast<char *>(port_str.c_str())};
   ```




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] fgerlits closed pull request #1035: MINIFI-1354: Memory leaks in nanofi and its unittests

Posted by GitBox <gi...@apache.org>.
fgerlits closed pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035


   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1035: MINIFI-1354: Memory leaks in nanofi and its unittests

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035#discussion_r603127503



##########
File path: nanofi/tests/CLogAggregatorTests.cpp
##########
@@ -31,18 +31,19 @@
 
 #include "CTestsBase.h"
 
-void test_lists_equal(token_list * tknlist, const std::vector<std::string>& sv) {
+void test_lists_equal(const token_list * tknlist, const std::vector<std::string>& sv) {
     REQUIRE(tknlist != NULL);
     if (sv.empty()) {

Review comment:
       ```
       REQUIRE(tknlist != NULL);
       REQUIRE(tknlist->size == sv.size());
       token_node *node = tknlist->head;
       for (const auto& s : sv) {
         REQUIRE(node);
         REQUIRE(strcmp(s.c_str(), node->data) == 0);
         node = node->next;
       }
       REQUIRE(node == nullptr);
   ```




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1035: MINIFI-1354: Memory leaks in nanofi and its unittests

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035#discussion_r603127503



##########
File path: nanofi/tests/CLogAggregatorTests.cpp
##########
@@ -31,18 +31,19 @@
 
 #include "CTestsBase.h"
 
-void test_lists_equal(token_list * tknlist, const std::vector<std::string>& sv) {
+void test_lists_equal(const token_list * tknlist, const std::vector<std::string>& sv) {
     REQUIRE(tknlist != NULL);
     if (sv.empty()) {

Review comment:
       ```suggestion
       REQUIRE(tknlist->size == sv.size());
       token_node *node = tknlist->head;
       for (const auto& s : sv) {
         REQUIRE(node);
         REQUIRE(strcmp(s.c_str(), node->data) == 0);
         node = node->next;
       }
       REQUIRE(node == nullptr);
   ```




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] martinzink commented on a change in pull request #1035: MINIFI-1354: Memory leaks in nanofi and its unittests

Posted by GitBox <gi...@apache.org>.
martinzink commented on a change in pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035#discussion_r601340336



##########
File path: nanofi/src/api/nanofi.cpp
##########
@@ -131,20 +131,26 @@ nifi_instance *create_instance_repo(const char *url, nifi_port *port, const char
   return instance;
 }
 
+nifi_instance * acquire_standalone_instance () {
+  if (standalone_instance == nullptr) {
+    nifi_port port;
+    auto port_str = utils::IdGenerator::getIdGenerator()->generate().to_string();
+    port.port_id = const_cast<char *>(port_str.c_str());

Review comment:
       changed in [6e43953](https://github.com/martinzink/nifi-minifi-cpp/commit/6e4395376e34445296946998d0110de92b24511e)




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] martinzink commented on pull request #1035: MINIFI-1354: Memory leaks in nanofi and its unittests

Posted by GitBox <gi...@apache.org>.
martinzink commented on pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035#issuecomment-806536205


   > Looks good, thanks for the fix. My question is, that would it be possible to have an ASAN build in the CI and have the sanitizer checks there as well?
   
   Yeah that would be ideal, unfortunetly there are still couple of issues we need to fix before that can be enabled. e.g. [MINIFICPP-839](https://issues.apache.org/jira/browse/MINIFICPP-839)


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org