Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org,
	Roman Khabibov <roman.habibov@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH] box: fix bug with module_reload() without box.cfg{}
Date: Tue, 5 Feb 2019 18:41:53 +0300	[thread overview]
Message-ID: <d8cdfb5b-866f-64b7-d8d5-878642323449@tarantool.org> (raw)
In-Reply-To: <20190205001737.8475-1-roman.habibov@tarantool.org>

Hi! Thanks for the patch! See 5 comments below.

On 05/02/2019 01:17, Roman Khabibov wrote:
> Fix bug with segfault when use module_reload() before box.cfg{}.

1. Instead of duplicating commit title, it is usually
better to describe here a reason why the bug existed.

> 
> Closes #3770
> 
> Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-3770-module-reload
> Issue: https://github.com/tarantool/tarantool/issues/3770

2. Please, put branch and issue links after '---'.

> ---

Here.

>   src/box/func.c                | 3 +++
>   test/box/func_reload.result   | 9 +++++++++
>   test/box/func_reload.test.lua | 5 +++++
>   3 files changed, 17 insertions(+)
> 
> diff --git a/src/box/func.c b/src/box/func.c
> index a817851fd..ee6dd55dc 100644
> --- a/src/box/func.c
> +++ b/src/box/func.c
> @@ -301,6 +301,9 @@ module_sym(struct module *module, const char *name)
>   int
>   module_reload(const char *package, const char *package_end, struct module **module)
>   {
> +	if (!modules)
> +		return -1;

3. As you know, we use == NULL instead of ! when dealing with pointers.

4. Instead of checking for modules != NULL in each public func.h function,
it is better to move module_init() call from box_cfg_xc() to box_init(). Then
main() will create modules hash.

> +
>   	struct module *old_module = module_cache_find(package, package_end);
>   	if (old_module == NULL) {
>   		/* Module wasn't loaded - do nothing. */
> diff --git a/test/box/func_reload.test.lua b/test/box/func_reload.test.lua
> index 8906898ec..00fe8cf48 100644
> --- a/test/box/func_reload.test.lua
> +++ b/test/box/func_reload.test.lua
> @@ -1,3 +1,8 @@
> +-- gh-3770 Check no segfault with module_reload() without box.cfg{}.
> +
> +box.internal.module_reload('')
> +box.internal.module_reload('xxx')

5. Not-tap tests are always run with already called box.cfg(),
so these lines here will work regardless of your patch. Please,
move it to a tap test, in app-tap directory. Now I do not see
there any existing and suitable file for this test, so you
should create a new one. For example, app-tap/func.test.lua.

> +
>   fio  = require('fio')
>   net = require('net.box')
>   fiber = require('fiber')
> -- 
> 2.17.1
> 
> 

  reply	other threads:[~2019-02-05 15:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05  0:17 [tarantool-patches] " Roman Khabibov
2019-02-05 15:41 ` Vladislav Shpilevoy [this message]
2019-02-07 11:31   ` [tarantool-patches] " Roman
2019-02-15 13:28     ` Vladislav Shpilevoy
2019-02-15 14:58 ` Kirill Yukhin

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=d8cdfb5b-866f-64b7-d8d5-878642323449@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=roman.habibov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH] box: fix bug with module_reload() without box.cfg{}' \
    /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