bugfix, See issue #1027

This commit is contained in:
Cloud Wu
2019-06-15 00:29:05 +08:00
parent 5a0f68999e
commit 6f0e88dc59
4 changed files with 12 additions and 4 deletions

View File

@@ -155,6 +155,7 @@ void luaF_shareproto (Proto *f) {
int i; int i;
if (f == NULL) if (f == NULL)
return; return;
makeshared(f);
MAKESHARED(f->source); MAKESHARED(f->source);
for (i = 0; i < f->sizek; i++) { for (i = 0; i < f->sizek; i++) {
if (ttnov(&f->k[i]) == LUA_TSTRING) if (ttnov(&f->k[i]) == LUA_TSTRING)

View File

@@ -266,8 +266,10 @@ static void reallymarkobject (global_State *g, GCObject *o) {
break; break;
} }
case LUA_TLCL: { case LUA_TLCL: {
if (!isshared(o)) {
white2gray(o); white2gray(o);
linkgclist(gco2lcl(o), g->gray); linkgclist(gco2lcl(o), g->gray);
}
break; break;
} }
case LUA_TCCL: { case LUA_TCCL: {

View File

@@ -935,6 +935,7 @@ new_string(unsigned int h, const char *str, lu_byte l) {
memset(ts, 0, sz); memset(ts, 0, sz);
setbits(ts->marked, WHITEBITS); setbits(ts->marked, WHITEBITS);
gray2black(ts); gray2black(ts);
makeshared(ts);
ts->tt = LUA_TSHRSTR; ts->tt = LUA_TSHRSTR;
ts->hash = h; ts->hash = h;
ts->shrlen = l; ts->shrlen = l;

View File

@@ -39,8 +39,12 @@ mark_shared(lua_State *L) {
case LUA_TLIGHTUSERDATA: case LUA_TLIGHTUSERDATA:
break; break;
case LUA_TFUNCTION: case LUA_TFUNCTION:
if (!lua_iscfunction(L, idx) || lua_getupvalue(L, idx, 1) != NULL) if (lua_getupvalue(L, idx, 1) != NULL) {
luaL_error(L, "Invalid function"); luaL_error(L, "Invalid function with upvalue");
} else if (!lua_iscfunction(L, idx)) {
LClosure *f = (LClosure *)lua_topointer(L, idx);
makeshared(f);
}
break; break;
case LUA_TSTRING: case LUA_TSTRING:
lua_sharestring(L, idx); lua_sharestring(L, idx);