lua-users home
lua-l archive

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


On Sat, Oct 15, 2011 at 4:41 PM, ijsf <ijsf@gmx-topmail.de> wrote:
> I have recently noticed a serious problem in Lua 5.1.4's luaD_precall
> function using Valgrind.
>
> The bug is basically a corrupt (outdated) stack pointer to a function,
> after the stack has been grown before calling a C function, though it
> may affect other types of calls as well.
>

The patch below seems to fix the problem. Apparently this was already
working properly for regular Lua functions (a few lines up_, but
someone neglected to check the other cases as well.

...
  else {  /* if is a C function, call it */
    CallInfo *ci;
    int n;
    luaD_checkstack(L, LUA_MINSTACK);  /* ensure minimum stack size */

Below, add the following line to ensure 'func' always points to the
correct stack:

    func = restorestack(L, funcr);

Regards.