From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 887B543D679 for ; Thu, 31 Oct 2019 01:08:21 +0300 (MSK) References: <71d3e28eadd9ca54d5f564ed25d4276d472d5e6d.1572432961.git.imeevma@gmail.com> From: Vladislav Shpilevoy Message-ID: <0dd15716-6130-3dc3-5019-c2228681ba08@tarantool.org> Date: Wed, 30 Oct 2019 23:13:54 +0100 MIME-Version: 1.0 In-Reply-To: <71d3e28eadd9ca54d5f564ed25d4276d472d5e6d.1572432961.git.imeevma@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH v1 1/1] netbox: fix memleak in lbox_tuple_format_new() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: imeevma@tarantool.org Cc: tarantool-patches@freelists.org, tarantool-patches@dev.tarantool.org Hi! Thanks for the patch! On 30/10/2019 11:58, imeevma@tarantool.org wrote: > Memleak appeared due to the fact that when creating a dictionary > its reference count is 1 from the beginning. Later, when the > dictionary is used to create tuple_format, its reference counter > increased by 1 and it became equal to 2. After removing > tuple_format, the reference counter for dict decreased by one, so > it became equal to 1. Since ref counter is not equal to 0, dict > not deleted, causing a memory leak. > > Closes #4588 > --- > src/box/lua/misc.cc | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/src/box/lua/misc.cc b/src/box/lua/misc.cc > index 7b8b9dc..102194e 100644 > --- a/src/box/lua/misc.cc > +++ b/src/box/lua/misc.cc > @@ -233,6 +233,7 @@ lbox_tuple_format_new(struct lua_State *L) > NULL, 0, 0, dict, false, false); > if (format == NULL) > return luaT_error(L); The dict should be unreferenced regardless of tuple_format_new() result. Now there is a leak, when format == NULL. > + tuple_dictionary_unref(dict); > return lbox_push_tuple_format(L, format); > } >