Skip to content
Snippets Groups Projects
Commit 0fb64e5a authored by Alexander Turenko's avatar Alexander Turenko Committed by Igor Munkin
Browse files

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
parent d688c50d
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment