Skip to content

Commit ae034cf

Browse files
authored
fix: use same hash seed when creating VM for shared tables (#2122)
When creating a new Lua VM to load shared tables, use the same hash seed from the parent VM instead of generating a new random seed. Different VMs have different hash seeds, causing identical strings to have different hash values. When looking up string keys in a shared table from another VM, the hash-based bucket lookup fails because the search key's hash doesn't match the stored key's hash. Solution: Pass G(L)->seed to lua_newstate() instead of using luaL_newstate() which generates a new random seed each time.
1 parent 022c619 commit ae034cf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lualib-src/lua-sharetable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ load_matrixfile(lua_State *L) {
192192

193193
static int
194194
matrix_from_file(lua_State *L) {
195-
lua_State *mL = luaL_newstate();
195+
lua_State *mL = lua_newstate(luaL_alloc, NULL, G(L)->seed);
196196
if (mL == NULL) {
197197
return luaL_error(L, "luaL_newstate failed");
198198
}

0 commit comments

Comments
 (0)