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

Memory leak if scheduling interval is invalid

    Details

    • Team:
      Team A
    • Sprint:
      Sprint 41
    • Story Points:
      0.25

      Description

      1. Create passive agent.ping item with scheduling interval {$INTERVAL}
      2. {$INTERVAL}=h9g/30

      Notice memory leak

      ==13454== 24 bytes in 1 blocks are definitely lost in loss record 147 of 431
      ==13454==    at 0x4C2EBAB: malloc (vg_replace_malloc.c:299)
      ==13454==    by 0x66E9EB: zbx_malloc2 (misc.c:491)
      ==13454==    by 0x671671: scheduler_parse_filter_r (misc.c:1132)
      ==13454==    by 0x671887: scheduler_parse_filter (misc.c:1171)
      ==13454==    by 0x671A3C: scheduler_interval_parse (misc.c:1207)
      ==13454==    by 0x675794: zbx_interval_preproc (misc.c:1851)
      ==13454==    by 0x581ADB: DCitem_nextcheck_update (dbconfig.c:345)
      ==13454==    by 0x59A0A6: DCsync_items (dbconfig.c:2775)
      ==13454==    by 0x5A815D: DCsync_configuration (dbconfig.c:4849)
      ==13454==    by 0x41D70B: MAIN_ZABBIX_ENTRY (server.c:1043)
      ==13454==    by 0x63182B: daemon_start (daemon.c:392)
      ==13454==    by 0x41D06D: main (server.c:854)
      ==13454== 
      ==13454== LEAK SUMMARY:
      ==13454==    definitely lost: 24 bytes in 1 blocks
      ==13454==    indirectly lost: 0 bytes in 0 blocks
      ==13454==      possibly lost: 0 bytes in 0 blocks
      ==13454==    still reachable: 112,750 bytes in 704 blocks
      ==13454==         suppressed: 56 bytes in 1 blocks
      ==13454== Reachable blocks (those to which a pointer was found) are not shown.
      ==13454== To see them, rerun with: --leak-check=full --show-leak-kinds=all
      

      Patch with possible fix:

      Index: src/libs/zbxcommon/misc.c
      ===================================================================
      --- src/libs/zbxcommon/misc.c	(revision 84132)
      +++ src/libs/zbxcommon/misc.c	(working copy)
      @@ -1848,16 +1848,17 @@
       			new_interval = (zbx_scheduler_interval_t *)zbx_malloc(NULL, sizeof(zbx_scheduler_interval_t));
       			memset(new_interval, 0, sizeof(zbx_scheduler_interval_t));
       
      -			if (SUCCEED != (ret = scheduler_interval_parse(new_interval, interval_str,
      -					(NULL == delim ? (int)strlen(interval_str) : (int)(delim - interval_str)))))
      +			ret = scheduler_interval_parse(new_interval, interval_str,
      +					(NULL == delim ? (int)strlen(interval_str) : (int)(delim - interval_str)));
      +
      +			new_interval->next = scheduling;
      +			scheduling = new_interval;
      +
      +			if (SUCCEED != ret)
       			{
      -				zbx_free(new_interval);
       				interval_type = "scheduling";
      -				goto out;
      +				break;
       			}
      -
      -			new_interval->next = scheduling;
      -			scheduling = new_interval;
       		}
       	}
       out:
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vso Vladislavs Sokurenko
                Reporter:
                vso Vladislavs Sokurenko
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: