Skip to content

Commit 059faeb

Browse files
committed
message: fix crash caused by closing Lua too early
Pending messages may have `.free` callbacks pointing to functions in loaded Lua C modules (DLL/SO). Closing Lua first invalidates these pointers, so `message.free` may call an invalid function.
1 parent 0d4d9f7 commit 059faeb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lualib-src/lhive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int l_worker_gc(lua_State *L)
215215
struct worker *w = (struct worker *)lua_touserdata(L, 1);
216216
if (unlikely(w->task_id != 0)) {
217217
silly_log_warn("[hive] A worker was still busy during GC. This may cause a memory leak report on exit. "
218-
"Check for blocking calls or infinite loops in hive tasks.");
218+
"Check for blocking calls or infinite loops in hive tasks.\n");
219219
// If the worker is still running in the thread pool,
220220
// the only possible reason it was garbage collected is that its Lua state has been closed.
221221
// In this case, we can rely on the process exit cleanup to handle it automatically.

silly-src/silly_worker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ void silly_worker_warnendless()
357357

358358
void silly_worker_exit()
359359
{
360-
lua_close(W->L);
361360
silly_queue_free(W->queue);
361+
lua_close(W->L);
362362
silly_free(W);
363363
}

0 commit comments

Comments
 (0)