Skip to content

Commit 81ce454

Browse files
committed
fix(lua): reject coroutine resumes during state teardown
1 parent a67be10 commit 81ce454

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lua/hvlua.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ HvLuaCoroutine* hvlua_suspend(lua_State* L) {
184184

185185
lua_State* hvlua_coroutine_state(HvLuaCoroutine* co) {
186186
if (co == NULL || co->ref == LUA_NOREF) return NULL;
187+
if (co->owner && co->owner->closing) return NULL;
187188
return co->L;
188189
}
189190

@@ -201,6 +202,10 @@ void hvlua_resume(HvLuaCoroutine* co, int nresults) {
201202
lua_State* L;
202203
int ref;
203204
if (co == NULL) return;
205+
if (co->owner && co->owner->closing) {
206+
hvlua_cancel(co);
207+
return;
208+
}
204209
if (co->ref == LUA_NOREF) { // stale: already resumed/freed
205210
HV_FREE(co);
206211
return;

0 commit comments

Comments
 (0)