From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (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 899E14696C3 for ; Thu, 16 Apr 2020 03:19:04 +0300 (MSK) References: <3ee69eaa4ff23647e9ae6fe63e2ae77c427ffe01.1586993218.git.korablev@tarantool.org> From: Vladislav Shpilevoy Message-ID: <574107d5-cb85-1b08-3abf-c2c53497ab5e@tarantool.org> Date: Thu, 16 Apr 2020 02:19:01 +0200 MIME-Version: 1.0 In-Reply-To: <3ee69eaa4ff23647e9ae6fe63e2ae77c427ffe01.1586993218.git.korablev@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH] box/error: ref error.prev while accessing it List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikita Pettik , tarantool-patches@dev.tarantool.org Hi! Thanks for the patch! See 2 minor comments below. > diff --git a/src/lib/core/diag.h b/src/lib/core/diag.h > index 7a5454d1c..beb6a7528 100644 > --- a/src/lib/core/diag.h > +++ b/src/lib/core/diag.h > @@ -118,25 +118,8 @@ error_ref(struct error *e) > e->refs++; > } > > -static inline void > -error_unref(struct error *e) 1. To reduce diff size and to keep inlining when possible you can remove word 'static', and add extern inline void error_unref(struct error *e); to diag.c. Yeah, exactly 'extern inline', not just 'extern'. I recently discovered that it is a special thing for such cases. > -{ > - assert(e->refs > 0); > - struct error *to_delete = e; > - while (--to_delete->refs == 0) { > - /* Unlink error from lists completely.*/ > - struct error *cause = to_delete->cause; > - assert(to_delete->effect == NULL); > - if (to_delete->cause != NULL) { > - to_delete->cause->effect = NULL; > - to_delete->cause = NULL; > - } > - to_delete->destroy(to_delete); > - if (cause == NULL) > - return; > - to_delete = cause; > - } > -} > +void > +error_unref(struct error *e); > > diff --git a/test/box/error.result b/test/box/error.result > index df6d0ebc0..49e35b942 100644 > --- a/test/box/error.result > +++ b/test/box/error.result > @@ -831,3 +831,51 @@ assert(box.error.last() == e1) > + | ... > +err.prev > + | --- > + | - null > + | ... > +preve > + | --- > + | - '[string "return function(tuple) local json = require(''..."]:1: attempt to call > + | global ''require'' (a nil value)' > + | ... > + > +s:drop() > + | --- > + | ... > +box.schema.func.drop('runtimeerror') 2. Did you check that preve does not leak when GC starts working? You can use setmetatable({}, {__mode = 'v'}) for that, see examples by grepping " __mode = 'v' ".