[ZBX-14771] Memory leak if scheduling interval is invalid Created: 2018 Aug 27  Updated: 2024 Apr 10  Resolved: 2018 Sep 03

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P), Server (S)
Affects Version/s: 3.4.13rc2, 4.0.0beta1
Fix Version/s: 3.4.14rc1, 4.0.0beta2, 4.0 (plan)

Type: Problem report Priority: Trivial
Reporter: Vladislavs Sokurenko Assignee: Vladislavs Sokurenko
Resolution: Fixed Votes: 0
Labels: interval, memoryleak, scheduling
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Causes
caused by ZBXNEXT-1675 Add macros support for update intervals Closed
Team: Team A
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:


 Comments   
Comment by Vladislavs Sokurenko [ 2018 Aug 28 ]

Fixed in development branch:
svn://svn.zabbix.com/branches/dev/ZBX-14771

Comment by Vladislavs Sokurenko [ 2018 Aug 29 ]

Fixed in:

  • pre-3.4.14rc1 r84321
  • pre-4.0.0beta2 (trunk) r84323
Generated at Sat Apr 20 05:36:34 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.