eris: fix objbarrier issue

This commit is contained in:
2021-12-10 14:47:03 -05:00
parent caf2803f6d
commit 1116dafc16

View File

@@ -1292,18 +1292,21 @@ u_proto(Info *info) { /* ... proto */
} }
poppath(info); poppath(info);
/* Read child protos. */ /* Allocate space for child protos */
/* Null all entries to avoid confusing the GC. */
int sizep = READ_VALUE(int); int sizep = READ_VALUE(int);
eris_reallocvector(info->L, p->p, 0, sizep, Proto*); eris_reallocvector(info->L, p->p, 0, sizep, Proto*);
memset(p->p, 0, sizep * sizeof(Proto*));
p->sizep = sizep; p->sizep = sizep;
/* Null all entries to avoid confusing the GC. */
memset(p->p, 0, p->sizep * sizeof(Proto*)); /* Read child protos. */
pushpath(info, ".protos"); pushpath(info, ".protos");
for (i = 0, n = p->sizep; i < n; ++i) { for (i = 0, n = p->sizep; i < n; ++i) {
Proto *cp; Proto *cp;
pushpath(info, "[%d]", i); pushpath(info, "[%d]", i);
p->p[i] = eris_newproto(info->L); p->p[i] = cp = eris_newproto(info->L);
lua_pushlightuserdata(info->L, (void*)p->p[i]); /* ... proto nproto */ luaC_objbarrier(info->L, p, cp);
lua_pushlightuserdata(info->L, (void*)cp); /* ... proto nproto */
unpersist(info); /* ... proto nproto nproto/oproto */ unpersist(info); /* ... proto nproto nproto/oproto */
cp = (Proto*)lua_touserdata(info->L, -1); cp = (Proto*)lua_touserdata(info->L, -1);
if (cp != p->p[i]) { /* ... proto nproto oproto */ if (cp != p->p[i]) { /* ... proto nproto oproto */