lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 25.06.2014 02:59 schröbte Pierre-Yves Gérardy:
I think I've found a bug in the C loader/seracher of Lua 5.1:

With the current version of require51 found at,
if the sentinel is a table, it ends up being populated by the C loader
as if it were the module.

The sentinel is not a table but a lightuserdata, so maybe the bug is in the current version of `require51` ... E.g. both `luaL_register` and the `module` function assume that the sentinel is _not_ a table (the C searcher has nothing to do with it, neither does the C loader unless it calls `luaL_register` with a non-NULL library name). Even with a non-table sentinel, `require51` doesn't work correctly with a module that uses `module` or `luaL_register` and doesn't return a value.

Also, the searcher can be any callable object, but the loader has to be a function.

For eample, requiring lpeg twice triggers the cycle detection code. If
the sentinel has another type, the error does not occur.

However it is nowhere passed as a parameter to anything... I suppose
it is left on the stack and coopted by the loader.