From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 178EE26144 for ; Mon, 4 Feb 2019 19:17:41 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qrCqq12-t0G4 for ; Mon, 4 Feb 2019 19:17:41 -0500 (EST) Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [94.100.177.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 5700726143 for ; Mon, 4 Feb 2019 19:17:40 -0500 (EST) From: Roman Khabibov Subject: [tarantool-patches] [PATCH] box: fix bug with module_reload() without box.cfg{} Date: Tue, 5 Feb 2019 03:17:36 +0300 Message-Id: <20190205001737.8475-1-roman.habibov@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org Fix bug with segfault when use module_reload() before box.cfg{}. Closes #3770 Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-3770-module-reload Issue: https://github.com/tarantool/tarantool/issues/3770 --- 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; + 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.result b/test/box/func_reload.result index b024cd143..e35ca41e2 100644 --- a/test/box/func_reload.result +++ b/test/box/func_reload.result @@ -1,3 +1,12 @@ +-- gh-3770 Check no segfault with module_reload() without box.cfg{}. +box.internal.module_reload('') +--- +- error: Module '' does not exist +... +box.internal.module_reload('xxx') +--- +- error: Module 'xxx' does not exist +... fio = require('fio') --- ... 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') + fio = require('fio') net = require('net.box') fiber = require('fiber') -- 2.17.1