diff --git a/extension/script/backend/bootstrap.lua b/extension/script/backend/bootstrap.lua index 6fa66113..45ab5b87 100644 --- a/extension/script/backend/bootstrap.lua +++ b/extension/script/backend/bootstrap.lua @@ -33,6 +33,7 @@ local function initMaster(rootpath, address) ExitGuard = setmetatable({}, {__gc=function() chan:push(nil, "EXIT") thread.wait(mt) + channel.destroy("DbgMaster") end}) end diff --git a/extension/script/backend/worker.lua b/extension/script/backend/worker.lua index ac149ba5..82129993 100644 --- a/extension/script/backend/worker.lua +++ b/extension/script/backend/worker.lua @@ -829,6 +829,7 @@ end function event.exit() sendToMaster 'exitWorker' {} + channel.destroy(WorkerChannel) end hookmgr.init(function(name, ...) diff --git a/extension/script/debugger.lua b/extension/script/debugger.lua index 677241c7..cf9314e9 100644 --- a/extension/script/debugger.lua +++ b/extension/script/debugger.lua @@ -187,7 +187,7 @@ function dbg:start(cfg) end function dbg:attach(cfg) - initDebugger(self, cfg) + initDebugger(self, cfg or {}) self.rdebug.start(([[ local rootpath = %q @@ -199,6 +199,10 @@ function dbg:attach(cfg) return self end +function dbg:stop() + self.rdebug.clear() +end + function dbg:event(...) self.rdebug.event(...) return self diff --git a/src/luadebug/rdebug_hookmgr.cpp b/src/luadebug/rdebug_hookmgr.cpp index 4c246bdf..7315662a 100644 --- a/src/luadebug/rdebug_hookmgr.cpp +++ b/src/luadebug/rdebug_hookmgr.cpp @@ -568,6 +568,10 @@ struct hookmgr { } luadebug::eventfree::destroy(hL, eventfree); lua_sethook(hL, 0, 0, 0); +#if defined(LUADEBUG_DISABLE_THUNK) + // clear hook manager pointer stored in thunk: + thunk_set(hL, &THUNK_MGR, intptr_t(nullptr)); +#endif #if defined(LUA_HOOKEXCEPTION) exception_open(hL, 0); #endif @@ -594,11 +598,13 @@ struct hookmgr { #else static int full_hook_callback(lua_State* hL, lua_Debug* ar) { hookmgr* mgr = (hookmgr*)thunk_get(hL, &THUNK_MGR); + if (!mgr) return 0; mgr->full_hook(hL, ar); return 0; } static int idle_hook_callback(lua_State* hL, lua_Debug* ar) { hookmgr* mgr = (hookmgr*)thunk_get(hL, &THUNK_MGR); + if (!mgr) return 0; mgr->idle_hook(hL, ar); return 0; }