diff mbox

[ovs-dev] ovsdb: using perf counter without initialization

Message ID 1450897095-35547-1-git-send-email-u9012063@gmail.com
State Accepted
Headers show

Commit Message

William Tu Dec. 23, 2015, 6:58 p.m. UTC
perf_counter_accumulate() is invoked without perf_counters_init() being
called first, which leads to a memory leak reported by Valgrind (test
cases 104, 106, and 107). A call trace is below:
    xmalloc (util.c:112)
    shash_add_nocopy__ (shash.c:109)
    shash_add_nocopy (shash.c:121)
    shash_add (shash.c:129)
    shash_add_once (shash.c:136)
    shash_add_assert (shash.c:146)
    perf_counter_init (perf-counter.c:86)
    perf_counter_accumulate (perf-counter.c:95)
    ovsdb_txn_commit (transaction.c:850)
    ovsdb_file_open__ (file.c:217)
    open_db (ovsdb-server.c:418)
    main (ovsdb-server.c:263)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
---
 ovsdb/ovsdb-server.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Ben Pfaff Dec. 23, 2015, 9:04 p.m. UTC | #1
On Wed, Dec 23, 2015 at 10:58:15AM -0800, William Tu wrote:
> perf_counter_accumulate() is invoked without perf_counters_init() being
> called first, which leads to a memory leak reported by Valgrind (test
> cases 104, 106, and 107). A call trace is below:
>     xmalloc (util.c:112)
>     shash_add_nocopy__ (shash.c:109)
>     shash_add_nocopy (shash.c:121)
>     shash_add (shash.c:129)
>     shash_add_once (shash.c:136)
>     shash_add_assert (shash.c:146)
>     perf_counter_init (perf-counter.c:86)
>     perf_counter_accumulate (perf-counter.c:95)
>     ovsdb_txn_commit (transaction.c:850)
>     ovsdb_file_open__ (file.c:217)
>     open_db (ovsdb-server.c:418)
>     main (ovsdb-server.c:263)
> 
> Signed-off-by: William Tu <u9012063@gmail.com>
> Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
> Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>

Thanks, applied to master and branch-2.5.
diff mbox

Patch

diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index 25fa9c6..231ba2f 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -259,6 +259,9 @@  main(int argc, char *argv[])
     shash_init(&all_dbs);
     server_config.all_dbs = &all_dbs;
     server_config.jsonrpc = jsonrpc;
+
+    perf_counters_init();
+
     SSET_FOR_EACH (db_filename, &db_filenames) {
         error = open_db(&server_config, db_filename);
         if (error) {
@@ -297,8 +300,6 @@  main(int argc, char *argv[])
 
     daemonize_complete();
 
-    perf_counters_init();
-
     if (!run_command) {
         /* ovsdb-server is usually a long-running process, in which case it
          * makes plenty of sense to log the version, but --run makes