-
Notifications
You must be signed in to change notification settings - Fork 33
Description
This was discussed in #547. Even though we are spending a bunch of time on a separate issue in that discussion, I am concerned this one is still an issue, so I want to file it so it doesn't get lost.
In the generated code from coder.lua, there are places that static variables are used for cache purposes.
static int cache = -1;
TValue *slot = pallene_getstr(9, x9, tsvalue(&K->uv[16].uv), &cache);
My concern is that if these values are not constant for all cases except maybe for some global one-time initialization, this could cause bugs and break user programs if they use multiple Lua VMs in their program. I don't fully understand what is being cached and the side effects of everything, but it raises alarm bells for me.
I was specifically thinking of Lua Lanes, which will have multiple instances of Lua VMs running concurrently across multiple threads. But I am concerned that even having just two different VMs that you run one after another could still potentially lead the second VM instance to pick up the static int cached value set from the prior first VM run instance, and maybe that cached value is now wrong for this second instance.