Hi! Thanks for review. On ²â, äÕÒ 5, 2019 at 6:42 PM, Vladislav Shpilevoy 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 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')