Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: Konstantin Osipov <kostja.osipov@gmail.com>,
	tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 1/2] vinyl: init all vars before cleanup in vy_lsm_split_range()
Date: Thu, 9 Apr 2020 11:26:00 +0000	[thread overview]
Message-ID: <20200409112559.GC3864@tarantool.org> (raw)
In-Reply-To: <20200409110756.GC29198@atlas>

On 09 Apr 14:07, Konstantin Osipov wrote:
> * Nikita Pettik <korablev@tarantool.org> [20/04/09 14:00]:
> > On 09 Apr 11:18, Konstantin Osipov wrote:
> > > * Nikita Pettik <korablev@tarantool.org> [20/04/09 00:39]:
> > > 
> > > > +	struct errinj *inj = errinj(ERRINJ_VY_MAX_TUPLE_SIZE, ERRINJ_INT);
> > > > +	if (inj != NULL && inj->iparam >= 0) {
> > > > +		if (inj->iparam-- == 0)
> > > > +			total_size = vy_max_tuple_size + 1;
> > > > +	}
> > > 
> > > shouldn't this be under #ifdef
> > 
> > Looks like not: most of other errinj() calls are not wrapped in
> > #ifdef NDEBUG macro (in case of debug build errinj() always
> > returns NULL).
> 
> In most cases the compiler can optimize these away, but the rules
> are complicated.
> Regarding other uses of errinj() one should take into
> consideration whether it's a hot path or not, whether the code
> in which injection is used is small/simple or not, etc.
> 
> I'd say as a rule of thumb anything using errinj and is multiline
> is better off using #ifdef.

Ok, as you wish, I don't mind this change. Diff:

diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c
index d2469961f..e822137ec 100644
--- a/src/box/vy_stmt.c
+++ b/src/box/vy_stmt.c
@@ -134,11 +134,13 @@ vy_stmt_alloc(struct tuple_format *format, uint32_t bsize)
 {
        uint32_t total_size = sizeof(struct vy_stmt) + format->field_map_size +
                bsize;
+#ifndef NDEBUG
        struct errinj *inj = errinj(ERRINJ_VY_MAX_TUPLE_SIZE, ERRINJ_INT);
        if (inj != NULL && inj->iparam >= 0) {
                if (inj->iparam-- == 0)
                        total_size = vy_max_tuple_size + 1;
        }
+#endif
        if (unlikely(total_size > vy_max_tuple_size)) {
                diag_set(ClientError, ER_VINYL_MAX_TUPLE_SIZE,
                         (unsigned) total_size);

 
> > > The patch is LGTM, please solicit another review.
> 
> -- 
> Konstantin Osipov, Moscow, Russia
> https://scylladb.com

  reply	other threads:[~2020-04-09 11:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08 21:37 [Tarantool-patches] [PATCH 0/2] vinyl: fix uninitialized memory accesses Nikita Pettik
2020-04-08 21:37 ` [Tarantool-patches] [PATCH 1/2] vinyl: init all vars before cleanup in vy_lsm_split_range() Nikita Pettik
2020-04-09  8:18   ` Konstantin Osipov
2020-04-09 10:55     ` Nikita Pettik
2020-04-09 11:07       ` Konstantin Osipov
2020-04-09 11:26         ` Nikita Pettik [this message]
2020-04-10 15:13   ` Vladislav Shpilevoy
2020-04-10 15:40     ` Nikita Pettik
2020-04-10 18:24       ` Nikita Pettik
2020-04-11 17:39       ` Vladislav Shpilevoy
2020-04-13 22:29         ` Nikita Pettik
2020-04-14 21:40           ` Nikita Pettik
2020-04-08 21:37 ` [Tarantool-patches] [PATCH 2/2] vinyl: clean-up read views if *_build_history() fails Nikita Pettik
2020-04-09  8:19   ` Konstantin Osipov
2020-04-09 11:09     ` Nikita Pettik
2020-04-10 15:13   ` Vladislav Shpilevoy
2020-04-10 15:47     ` Nikita Pettik
2020-04-10 21:45       ` Nikita Pettik
2020-04-10 22:32         ` Vladislav Shpilevoy
2020-04-11 17:30           ` Konstantin Osipov
2020-04-13 22:31             ` Nikita Pettik
2020-04-13 22:35               ` Konstantin Osipov
2020-04-13 22:11           ` Nikita Pettik
2020-04-11 17:39       ` Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200409112559.GC3864@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=kostja.osipov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/2] vinyl: init all vars before cleanup in vy_lsm_split_range()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox