Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/16265 )
Change subject: [tests] fix potential memory leak ...................................................................... Patch Set 1: (1 comment) http://gerrit.cloudera.org:8080/#/c/16265/1/src/kudu/tools/kudu-tool-test.cc File src/kudu/tools/kudu-tool-test.cc: http://gerrit.cloudera.org:8080/#/c/16265/1/src/kudu/tools/kudu-tool-test.cc@913 PS1, Line 913: STLDeleteValues(&ts_map_); > nit: would it be possible to put this into CreateTabletServerMap() instead, I intentionally didn't put that into CreateTabletServerMap(), and the reason is CreateTabletServerMap()'s signature. The third parameter of the function allows for passing in a container that contains pointers to TServerDetails which are referred from other unordered_map<string, TServerDetails*> container, and those might be de-allocated at the upper level as well. That would be double-free error. Instead, I removed ts_map->clear() and added CHECK(ts_map->empty()) into CreateTabletServerMap() to track programming errors associated with the current clumsy signature and semantics of CreateTabletServerMap() function. Overall, I think unordered_map<string, TServerDetails*> should be replaced by unordered_map<string, unique_ptr<TServerDetails>> or unordered_map<string, shared_ptr<TServerDetails>>, but I don't want to do this right now because it's a lot of yak shaving. -- To view, visit http://gerrit.cloudera.org:8080/16265 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: kudu Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ie2e6132eb4cb027055b1523ff4e89d206d7eb973 Gerrit-Change-Number: 16265 Gerrit-PatchSet: 1 Gerrit-Owner: Alexey Serbin <[email protected]> Gerrit-Reviewer: Alexey Serbin <[email protected]> Gerrit-Reviewer: Andrew Wong <[email protected]> Gerrit-Reviewer: Bankim Bhavsar <[email protected]> Gerrit-Reviewer: Kudu Jenkins (120) Gerrit-Comment-Date: Fri, 31 Jul 2020 18:04:18 +0000 Gerrit-HasComments: Yes
