[ZBX-8948] Memory leak when checking action condition "Template" = <template name> Created: 2014 Oct 24  Updated: 2017 May 30  Resolved: 2014 Oct 25

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 2.0.13, 2.2.6, 2.4.1, 2.5.0
Fix Version/s: 2.0.14rc1, 2.2.8rc1, 2.4.2rc1, 2.5.0

Type: Incident report Priority: Blocker
Reporter: Andris Zeila Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: memoryleak
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBX-8256 Memory leak on history syncer process Closed
is duplicated by ZBX-8363 DB2 queries can be failed with critic... Closed

 Description   

In the following code at src/zabbix_server/actions.c:116

do
{
	result = DBselect(
			"select distinct i.hostid,t.templateid"
			" from items i,functions f,triggers t"
			" where i.itemid=f.itemid"
				" and f.triggerid=t.templateid"
				" and t.triggerid=" ZBX_FS_UI64,
			triggerid);

	if (NULL != (row = DBfetch(result)))
	{
		ZBX_STR2UINT64(hostid, row[0]);
		ZBX_STR2UINT64(triggerid, row[1]);

		if (hostid == condition_value)
		{
			ret = SUCCEED;
			break;
		}
	}
	else
		triggerid = 0;
	DBfree_result(result);
}
while (SUCCEED != ret && 0 != triggerid);

the result variable might not be freed with DBfree_result().

A patch to fix it:

Index: src/zabbix_server/actions.c
===================================================================
--- src/zabbix_server/actions.c (revision 50119)
+++ src/zabbix_server/actions.c (working copy)
@@ -129,10 +129,7 @@
                                                ZBX_STR2UINT64(triggerid, row[1]);
 
                                                if (hostid == condition_value)
-                                               {
                                                        ret = SUCCEED;
-                                                       break;
-                                               }
                                        }
                                        else
                                                triggerid = 0;



 Comments   
Comment by Andris Zeila [ 2014 Oct 24 ]

This might be the reason for DB2 handle leak in ZBX-8363 and memory leak in ZBX-8256

Comment by Andris Zeila [ 2014 Oct 24 ]

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

Comment by Andris Zeila [ 2014 Oct 24 ]

Releaed in:

  • pre-2.0.14rc1 r50166
  • pre-2.2.8rc1 r50167
  • pre-2.4.2rc1 r50168
  • pre-2.5.0 r50169
Comment by richlv [ 2014 Oct 25 ]

(1) this change went in both 2.4 and trunk. the changelog entry is present for 2.5.0 - i believe it should not be

sasha Thanks! Removed directly from trunk in r50187.

CLOSED

Comment by Alexander Vladishev [ 2014 Oct 25 ]

This memory leak can be in "History syncer" and "Timer" processes on server side when processing of action conditions "Template = <template name>".

Generated at Fri Mar 29 16:05:52 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.