lua-users home
lua-l archive

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


On Fri, Apr 4, 2014 at 8:44 AM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> You'd think that read-only access to the a shared global_State from
> different lua_State's (coroutines.create()) would be possible without a
> global interpreter lock.

You'd think that, yes, but as soon as you try it you'll see there are
problems. Consider
        lua_getglobal(L,"myvar")
Is that a read-only access to L? It seems so but it may not be if "myvar"
is not in the string table. The implementation of lua_getglobal finds
"myvar" in the string table by actually adding it to the string table.
(In the current version of Lua this only ends up actually adding the var
name to the string table if the var name is longer than 40, but that is
an implementation detail.)


That is a subtle "gotcha"... I still wonder what you can get away with if you're making sure you modify unrelated areas of the global_State without locks.