From: Roman <roman.habibov@tarantool.org> To: tarantool-patches@freelists.org Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Subject: [tarantool-patches] Re: [PATCH] box: fix bug with module_reload() without box.cfg{} Date: Thu, 07 Feb 2019 14:31:13 +0300 [thread overview] Message-ID: <1549539073.27209.0@smtp.mail.ru> (raw) In-Reply-To: <d8cdfb5b-866f-64b7-d8d5-878642323449@tarantool.org> [-- Attachment #1: Type: text/plain, Size: 3341 bytes --] Hi! Thanks for review. On Вт, фев 5, 2019 at 6:42 PM, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> wrote: > Hi! Thanks for the patch! See 5 comments below. > 1. Instead of duplicating commit title, it is usually > better to describe here a reason why the bug existed. Done. > > 2. Please, put branch and issue links after '---'. > >> --- Sorry. > 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. diff --git a/src/box/box.cc b/src/box/box.cc index 8892d0f0e..6494a0f44 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -2053,6 +2053,9 @@ box_init(void) */ session_init(); + if (module_init() != 0) + diag_raise(); + if (tuple_init(lua_hash) != 0) diag_raise(); @@ -2080,8 +2083,6 @@ box_cfg_xc(void) gc_init(); engine_init(); - if (module_init() != 0) - diag_raise(); schema_init(); replication_init(); port_init(); > 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. diff --git a/test/app-tap/func.test.lua b/test/app-tap/func.test.lua new file mode 100755 index 000000000..11bc01f1d --- /dev/null +++ b/test/app-tap/func.test.lua @@ -0,0 +1,14 @@ +#!/usr/bin/env tarantool + +local tap = require('tap') + +local test = tap.test("func") + +test:plan(2) + +-- gh-3770 Check no segfault with module_reload() without box.cfg{}. + +test:ok(not pcall(box.internal.module_reload, ''), + 'expected error: no module') +test:ok(not pcall(box.internal.module_reload, 'xxx'), + 'expected error: no module') commit afd765d8bc86188c33cba3f06478853ec76bcaea Author: Roman Khabibov <roman.habibov@tarantool.org> Date: Tue Feb 5 03:04:33 2019 +0300 box: fix bug with module_reload() without box.cfg{} A bug existed because module_init was called during a call to box_cfg{}. Modules were not initialized before calling box.cfg{}. Closes #3770 diff --git a/src/box/box.cc b/src/box/box.cc index 8892d0f0e..6494a0f44 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -2053,6 +2053,9 @@ box_init(void) */ session_init(); + if (module_init() != 0) + diag_raise(); + if (tuple_init(lua_hash) != 0) diag_raise(); @@ -2080,8 +2083,6 @@ box_cfg_xc(void) gc_init(); engine_init(); - if (module_init() != 0) - diag_raise(); schema_init(); replication_init(); port_init(); diff --git a/test/app-tap/func.test.lua b/test/app-tap/func.test.lua new file mode 100755 index 000000000..11bc01f1d --- /dev/null +++ b/test/app-tap/func.test.lua @@ -0,0 +1,14 @@ +#!/usr/bin/env tarantool + +local tap = require('tap') + +local test = tap.test("func") + +test:plan(2) + +-- gh-3770 Check no segfault with module_reload() without box.cfg{}. + +test:ok(not pcall(box.internal.module_reload, ''), + 'expected error: no module') +test:ok(not pcall(box.internal.module_reload, 'xxx'), + 'expected error: no module') [-- Attachment #2: Type: text/html, Size: 4424 bytes --]
next prev parent reply other threads:[~2019-02-07 11:31 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 ` [tarantool-patches] " Vladislav Shpilevoy 2019-02-07 11:31 ` Roman [this message] 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=1549539073.27209.0@smtp.mail.ru \ --to=roman.habibov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.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