lua-users home
lua-l archive

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


On Fri, Jan 1, 2016 at 8:09 PM, Coda Highland <chighland@gmail.com> wrote:
On Fri, Jan 1, 2016 at 6:30 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
> The bug is quite subtle. Follows a fix:
>
> diff for lvm.c:
> ----------------------------------------
> 193c193,194
> <       lua_assert(ttistable(t) && ttisnil(oldval));
> ---
> >       Table *h = hvalue(t);
> >       lua_assert(ttisnil(oldval));
> 195c196
> <       if ((tm = fasttm(L, hvalue(t)->metatable, TM_NEWINDEX)) == NULL &&
> ---
> >       if ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL &&
> 200c201
> <          (oldval = luaH_newkey(L, hvalue(t), key), 1))) {
> ---
> >          (oldval = luaH_newkey(L, h, key), 1))) {
> 203,204c204,205
> <         invalidateTMcache(hvalue(t));
> <         luaC_barrierback(L, hvalue(t), val);
> ---
> >         invalidateTMcache(h);
> >         luaC_barrierback(L, h, val);

that IS subtle

Does the bug caused by GC, unexpectedly changing the "gc" field, hence the hvalue(t) is not a constant?