From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp33.i.mail.ru (smtp33.i.mail.ru [94.100.177.93]) (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 C508746970E for ; Mon, 3 Feb 2020 17:39:28 +0300 (MSK) Date: Mon, 3 Feb 2020 17:39:28 +0300 From: Sergey Ostanevich Message-ID: <20200203143928.GG547@tarantool.org> References: <20200128192249.10023-1-gorcunov@gmail.com> <20200128192249.10023-3-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200128192249.10023-3-gorcunov@gmail.com> Subject: Re: [Tarantool-patches] [PATCH v7 2/5] box/applier: add missing diag_set on region_alloc failure List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tml Hi! Thanks for the patch! LGTM. Sergos On 28 Jan 22:22, Cyrill Gorcunov wrote: > In case if we're hitting memory limit allocating triggers > we should setup diag error to prevent nil dereference > in diag_raise call (for example from applier_apply_tx). > > Note that there are region_alloc_xc helpers which are > throwing errors but as far as I understand we need the > rollback action to process first instead of immediate > throw/catch thus we use diag_set. > > Signed-off-by: Cyrill Gorcunov > --- > src/box/applier.cc | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/src/box/applier.cc b/src/box/applier.cc > index ae3d281a5..2ed5125d0 100644 > --- a/src/box/applier.cc > +++ b/src/box/applier.cc > @@ -796,8 +796,11 @@ applier_apply_tx(struct stailq *rows) > sizeof(struct trigger)); > on_commit = (struct trigger *)region_alloc(&txn->region, > sizeof(struct trigger)); > - if (on_rollback == NULL || on_commit == NULL) > + if (on_rollback == NULL || on_commit == NULL) { > + diag_set(OutOfMemory, sizeof(struct trigger), > + "region_alloc", "on_rollback/on_commit"); > goto rollback; > + } > > trigger_create(on_rollback, applier_txn_rollback_cb, NULL, NULL); > txn_on_rollback(txn, on_rollback); > -- > 2.20.1 >