Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-18784

Memory leak in vmware_service_put_event_data

    XMLWordPrintable

    Details

    • Team:
      Team C
    • Sprint:
      Sprint 71 (Dec 2020)
    • Story Points:
      0.125

      Description

      1.

      ./configure -q --with-openssl --with-net-snmp --enable-agent --enable-server --enable-proxy --with-mysql --with-libcurl --enable-ipv6 --with-libxml2 --prefix=$(pwd)
      

      2. compile, install, run server like:

      valgrind -v --tool=memcheck  --leak-check=full --trace-children=yes --track-origins=yes --time-stamp=yes --max-stackframe=3475144  --log-file=/tmp/zabbix_server_VALGRIND --leak-resolution=high --show-leak-kinds=all sbin/zabbix_server -c /home/arimdjonoks/zabbix/etc/zabbix_server.conf -f
      

      3. add the "VMware" template
      4. set following macros:

      {$VMWARE.PASSWORD} xxx
      {$VMWARE.URL} https://192.168.3.15/sdk
      {$VMWARE.USERNAME} yyy
      

      5. "Execute now" discovery
      6. make sure discovered hosts appear in the list.
      7. remove template, stop the valgrind and check its output, it shows the following:

      ==00:00:27:21.399 3951== 2,600 bytes in 25 blocks are definitely lost in loss record 975 of 1,041
      ==00:00:27:21.399 3951==    at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==00:00:27:21.399 3951==    by 0x7F3DAF9: strdup (strdup.c:42)
      ==00:00:27:21.399 3951==    by 0x28DDEF: zbx_strdup2 (misc.c:673)
      ==00:00:27:21.399 3951==    by 0x19F38F: zbx_xml_read_node_value (vmware.c:6189)
      ==00:00:27:21.399 3951==    by 0x19F943: vmware_service_put_event_data (vmware.c:3773)
      ==00:00:27:21.399 3951==    by 0x1A91D0: vmware_service_parse_event_data (vmware.c:3946)
      ==00:00:27:21.399 3951==    by 0x1A91D0: vmware_service_get_event_data (vmware.c:4027)
      ==00:00:27:21.399 3951==    by 0x1A91D0: vmware_service_update (vmware.c:4863)
      ==00:00:27:21.399 3951==    by 0x1AA0AD: vmware_thread (vmware.c:5949)
      ==00:00:27:21.399 3951==    by 0x287886: zbx_thread_start (threads.c:136)
      ==00:00:27:21.399 3951==    by 0x163FC9: MAIN_ZABBIX_ENTRY (server.c:1348)
      ==00:00:27:21.399 3951==    by 0x27C53C: daemon_start (daemon.c:398)
      ==00:00:27:21.399 3951==    by 0x15C4BF: main (server.c:1001)
      ==00:00:27:21.399 3951==
      
      
      ==00:00:27:21.404 3951== 92,160 bytes in 90 blocks are definitely lost in loss record 1,036 of 1,041
      ==00:00:27:21.404 3951==    at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==00:00:27:21.404 3951==    by 0x28DCC7: zbx_malloc2 (misc.c:622)
      ==00:00:27:21.404 3951==    by 0x292D70: zbx_dvsprintf (str.c:738)
      ==00:00:27:21.404 3951==    by 0x292EB3: zbx_dsprintf (str.c:781)
      ==00:00:27:21.404 3951==    by 0x19FBA0: vmware_service_put_event_data (vmware.c:3801)
      ==00:00:27:21.404 3951==    by 0x1A91D0: vmware_service_parse_event_data (vmware.c:3946)
      ==00:00:27:21.404 3951==    by 0x1A91D0: vmware_service_get_event_data (vmware.c:4027)
      ==00:00:27:21.404 3951==    by 0x1A91D0: vmware_service_update (vmware.c:4863)
      ==00:00:27:21.404 3951==    by 0x1AA0AD: vmware_thread (vmware.c:5949)
      ==00:00:27:21.404 3951==    by 0x287886: zbx_thread_start (threads.c:136)
      ==00:00:27:21.404 3951==    by 0x163FC9: MAIN_ZABBIX_ENTRY (server.c:1348)
      

      Removing the following lines silences the leak report:

      diff --git a/src/zabbix_server/vmware/vmware.c b/src/zabbix_server/vmware/vmware.c
      index 8b58c486e3..949ee2b0d8 100644
      --- a/src/zabbix_server/vmware/vmware.c
      +++ b/src/zabbix_server/vmware/vmware.c
      @@ -3798,8 +3798,8 @@ static int        vmware_service_put_event_data(zbx_vector_ptr_t *events, zbx_id_xmlnod
                              if (NULL == host_nodes[i].name)
                                      continue;
       
      -                       message = zbx_dsprintf(message, "%s%s%s", message, host_nodes[i].name,
      -                                       0 != (host_nodes[i].flag & ZBX_HOSTINFO_NODES_HOST) ? "" : "/");
      +                       //      message = zbx_dsprintf(message, "%s%s%s", message, host_nodes[i].name,
      +                       //              0 != (host_nodes[i].flag & ZBX_HOSTINFO_NODES_HOST) ? "" : "/");
                              zbx_free(host_nodes[i].name);
                      }
              }
      @@ -3813,7 +3813,7 @@ static int        vmware_service_put_event_data(zbx_vector_ptr_t *events, zbx_id_xmlnod
       
                      if (NULL != (ip = zbx_xml_read_node_value(xdoc, xml_event.xml_node, ZBX_XPATH_NN("ipAddress"))))
                      {
      -                       message = zbx_dsprintf(message, "%s\n\nsource: %s", message, ip);
      +                 //message = zbx_dsprintf(message, "%s\n\nsource: %s", message, ip);
                              zbx_free(ip);
                      }
              }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              MVekslers Michael Veksler
              Reporter:
              arimdjonoks Artjoms Rimdjonoks
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: