lua: panic on suspicious built-in modules manipulations
The built-in module registration process performs several assertions: - luaT_newmodule() checks for attempts to register an already registered module. - luaT_setmodule() does the same, but it allows the same value be 'registered' several times. Attempt to register different values as the same built-in module is definitely an error. Once a module is registered, it may be required and captured. If its value is changed afterwards, different parts of tarantool's code will capture different values for the same built-in module. It is very unlikely that such effect may be intended. Anyway, tarantool's code doesn't do this. However, now, after implementing the override modules feature, it is possible to influence tarantool's initialization from a user provided code. It means that we can't assume the situations described above as impossible ones. A developer of an override module should receive an error if the code of the module leads to such a situation. `assert()` works only in Debug build, but most of user's code is tested on RelWithDebInfo builds. So incorrect override module may be implemented and distributed. It is undesirable. Let's replace `assert()` with explicit `panic()`. Adjusted testing helpers: * `treegen` now allows to just write given script into given directory without using templates. Sometimes it is more convenient. * `justrun` can return pure stdout (without JSONL decoding) and can return stderr if requested. `nojson` option in `justrun` may look unneeded for given test cases, but it provides better diagnostics if something going wrong and one of the test cases fails (say, if tarantool runs successfully instead of going to panic). Follows up #7774 NO_DOC=The override modules feature is not released yet. NO_CHANGELOG=see NO_DOC
Showing
- src/lua/utils.c 6 additions, 4 deletionssrc/lua/utils.c
- src/lua/utils.h 4 additions, 2 deletionssrc/lua/utils.h
- test/app-luatest/override_panic_test.lua 74 additions, 0 deletionstest/app-luatest/override_panic_test.lua
- test/justrun.lua 84 additions, 7 deletionstest/justrun.lua
- test/treegen.lua 18 additions, 13 deletionstest/treegen.lua
Loading
Please register or sign in to comment