From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Serge Petrenko <sergepetrenko@tarantool.org>
Cc: tml <tarantool-patches@dev.tarantool.org>,
Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH v20 1/7] box/schema: make sure hashes are created
Date: Mon, 5 Apr 2021 12:50:35 +0300 [thread overview]
Message-ID: <YGrda++uaqV0teIB@grain> (raw)
In-Reply-To: <01f1a611-8eb2-4d82-88f5-0f3912cbf6b0@tarantool.org>
On Mon, Apr 05, 2021 at 12:28:50PM +0300, Serge Petrenko wrote:
> > diff --git a/src/box/schema.cc b/src/box/schema.cc
> > index 963278b19..89904e4d2 100644
> > --- a/src/box/schema.cc
> > +++ b/src/box/schema.cc
> > @@ -372,6 +372,13 @@ schema_init(void)
> > funcs = mh_i32ptr_new();
> > funcs_by_name = mh_strnptr_new();
> > sequences = mh_i32ptr_new();
> > +
> > + if (spaces == NULL || spaces_by_name == NULL ||
> > + funcs == NULL || funcs_by_name == NULL ||
> > + sequences == NULL) {
> > + panic("Can't allocate schema hashes");
> > + }
>
> I've just noticed, all the mh_..._new methods will fail on a null
> dereference even before returning. So the check above doesn't
> make much sense.
This is because our lib/salad/mhash.h is simply buggy and it must be:
1) fixed in mhash level
2) get rid of this macros madness and convert it to normal
library. this macros spreading is over the top already
and I don't understand why nobody cares about icache footprint
Nevertheless we should check for x_new resuls as we do in our
other code. Let walk over spaces
schema_init
spaces = mh_i32ptr_new();
...
sc_space_new
space_cache_replace(NULL, space);
mh_int_t k = mh_i32ptr_put(spaces, &node_p, ...
which is simply nil dereferencing (once we fix bullet 1).
>
> But I see that some other places have this check
> `if (smth = mh_smth_new() == NULL)` and set an error.
>
> Am I missing something?
I think the idea was that mh_x_new doesn't do nil dereference
by its own but behaves in a safe way as any library routine
should. That said I still think we should check for mh_i32ptr_new
results. But won't insist to include this patch, we can drop it
if you prefer.
next prev parent reply other threads:[~2021-04-05 9:50 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-02 12:34 [Tarantool-patches] [PATCH v20 0/7] box: implement box.lib Lua module Cyrill Gorcunov via Tarantool-patches
2021-04-02 12:34 ` [Tarantool-patches] [PATCH v20 1/7] box/schema: make sure hashes are created Cyrill Gorcunov via Tarantool-patches
2021-04-05 9:28 ` Serge Petrenko via Tarantool-patches
2021-04-05 9:50 ` Cyrill Gorcunov via Tarantool-patches [this message]
2021-04-05 10:13 ` Serge Petrenko via Tarantool-patches
2021-04-05 15:45 ` Vladislav Shpilevoy via Tarantool-patches
2021-04-06 7:44 ` Cyrill Gorcunov via Tarantool-patches
2021-04-02 12:34 ` [Tarantool-patches] [PATCH v20 2/7] box/func: module_reload -- drop redundant argument Cyrill Gorcunov via Tarantool-patches
2021-04-05 10:23 ` Serge Petrenko via Tarantool-patches
2021-04-05 10:26 ` Serge Petrenko via Tarantool-patches
2021-04-05 10:31 ` Cyrill Gorcunov via Tarantool-patches
2021-04-02 12:34 ` [Tarantool-patches] [PATCH v20 3/7] box/func: fix modules functions restore Cyrill Gorcunov via Tarantool-patches
2021-04-05 10:53 ` Serge Petrenko via Tarantool-patches
2021-04-05 11:26 ` Cyrill Gorcunov via Tarantool-patches
2021-04-05 11:42 ` Serge Petrenko via Tarantool-patches
2021-04-05 15:47 ` Vladislav Shpilevoy via Tarantool-patches
2021-04-06 8:38 ` Cyrill Gorcunov via Tarantool-patches
2021-04-06 20:02 ` Vladislav Shpilevoy via Tarantool-patches
2021-04-06 20:42 ` Cyrill Gorcunov via Tarantool-patches
2021-04-02 12:34 ` [Tarantool-patches] [PATCH v20 4/7] box/module_cache: introduce modules subsystem Cyrill Gorcunov via Tarantool-patches
2021-04-05 12:34 ` Serge Petrenko via Tarantool-patches
2021-04-05 15:52 ` Vladislav Shpilevoy via Tarantool-patches
2021-04-06 14:33 ` Cyrill Gorcunov via Tarantool-patches
2021-04-06 20:09 ` Vladislav Shpilevoy via Tarantool-patches
2021-04-06 22:05 ` Cyrill Gorcunov via Tarantool-patches
2021-04-06 23:43 ` Vladislav Shpilevoy via Tarantool-patches
2021-04-07 7:03 ` Cyrill Gorcunov via Tarantool-patches
2021-04-02 12:34 ` [Tarantool-patches] [PATCH v20 5/7] box/schema.func: switch to new module api Cyrill Gorcunov via Tarantool-patches
2021-04-05 15:56 ` Vladislav Shpilevoy via Tarantool-patches
2021-04-02 12:34 ` [Tarantool-patches] [PATCH v20 6/7] box: implement box.lib module Cyrill Gorcunov via Tarantool-patches
2021-04-05 16:04 ` Vladislav Shpilevoy via Tarantool-patches
2021-04-07 16:59 ` Cyrill Gorcunov via Tarantool-patches
2021-04-07 20:22 ` Cyrill Gorcunov via Tarantool-patches
2021-04-07 20:28 ` Vladislav Shpilevoy via Tarantool-patches
2021-04-07 20:37 ` Cyrill Gorcunov via Tarantool-patches
2021-04-07 20:45 ` Cyrill Gorcunov via Tarantool-patches
2021-04-07 21:04 ` Vladislav Shpilevoy via Tarantool-patches
2021-04-02 12:34 ` [Tarantool-patches] [PATCH v20 7/7] test: add box.lib test Cyrill Gorcunov via Tarantool-patches
2021-04-05 16:04 ` Vladislav Shpilevoy via Tarantool-patches
2021-04-05 15:45 ` [Tarantool-patches] [PATCH v20 0/7] box: implement box.lib Lua module Vladislav Shpilevoy via Tarantool-patches
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=YGrda++uaqV0teIB@grain \
--to=tarantool-patches@dev.tarantool.org \
--cc=gorcunov@gmail.com \
--cc=sergepetrenko@tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v20 1/7] box/schema: make sure hashes are created' \
/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