From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp34.i.mail.ru (smtp34.i.mail.ru [94.100.177.94]) (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 760FD441841 for ; Wed, 25 Mar 2020 04:40:11 +0300 (MSK) Date: Wed, 25 Mar 2020 01:40:10 +0000 From: Nikita Pettik Message-ID: <20200325014010.GD30598@tarantool.org> References: <6ea1b78d9b2ddf8a56d39391c14262103b35d26c.1582119629.git.korablev@tarantool.org> <33767c0b-2bb6-8bf3-87a5-d3b1994f05d0@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <33767c0b-2bb6-8bf3-87a5-d3b1994f05d0@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 5/7] box/error: clarify purpose of reference counting in struct error List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org On 23 Feb 18:43, Vladislav Shpilevoy wrote: > Thanks for the patch! > > How about merging this commit into the previous one? > > On 19/02/2020 15:16, Nikita Pettik wrote: > > --- > > src/lib/core/diag.h | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/src/lib/core/diag.h b/src/lib/core/diag.h > > index 5271733cb..a9181c522 100644 > > --- a/src/lib/core/diag.h > > +++ b/src/lib/core/diag.h > > @@ -72,6 +72,15 @@ struct error { > > error_f raise; > > error_f log; > > const struct type_info *type; > > + /** > > + * Reference counting is basically required since > > + * instances of this structure are available in Lua > > + * as well (as cdata with overloaded fields and methods > > + * by the means of introspection). Thus, it may turn > > + * out that Lua's GC attempts at releasing object > > + * meanwhile it is still used in C internals or vice > > + * versa. For details see luaT_pusherror(). > > Hmm, no, it can't anymore. Now it can't. But it used to, until ref in luaT_pusherror() was introduced. So may comment refer to that quite ancient fix (I just wondered why can't we get rid of ref counter and came up with this explanation). > Lua can't delete an error object, > if it is still used in C. This looks like an artifact from the > previous patch version, were you unreferenced all errors when > diag was cleared. > > > + */ > > int refs; > > /** > > * Errno at the moment of the error > >