• sundb's avatar
    Add missing lua_pop in luaGetFromRegistry (#11097) · 8aad2ac3
    sundb authored
    This pr mainly has the following four changes:
    
    1. Add missing lua_pop in `luaGetFromRegistry`.
        This bug affects `redis.register_function`, where `luaGetFromRegistry` in
        `luaRegisterFunction` will return null when we call `redis.register_function` nested.
        .e.g
        ```
        FUNCTION LOAD "#!lua name=mylib \n local lib=redis \n lib.register_function('f2', function(keys, args) lib.register_function('f1', function () end) end)"
        fcall f2 0
        ````
        But since we exit when luaGetFromRegistry returns null, it does not cause the stack to grow indefinitely.
    
    3. When getting `REGISTRY_RUN_CTX_NAME` from the registry, use `serverAssert`
        instead of error return. Since none of these lua functions are registered at the time
        of function load, scriptRunCtx will never be NULL.
    4. Add `serverAssert` for `luaLdbLineHook`, `luaEngineLoadHook`.
    5. Remove `luaGetFromRegistry` from `redis_math_random` and
        `redis_math_randomseed`, it looks like they are redundant.
    8aad2ac3
eval.c 60.3 KB