From 146105602fb942c7bdcefe7742c1cfc3b1986fda Mon Sep 17 00:00:00 2001 From: SD Asif Hossein Date: Sun, 18 Aug 2024 22:31:19 +0600 Subject: [PATCH 1/2] Supply the traceback function to use against xpcall --- pt-lua.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pt-lua.c b/pt-lua.c index 40f6084..f65f4cf 100644 --- a/pt-lua.c +++ b/pt-lua.c @@ -983,6 +983,10 @@ int main (int argc, char **argv) { /* -------- PALLENE TRACER CODE -------- */ (void) pallene_tracer_init(L); /* initialize pallene tracer */ lua_pop(L, 1); /* We do not need the finalizer object here */ + + /* supply the message handler function with custom tracebacks. */ + lua_pushcfunction(L, msghandler); + lua_setglobal(L, "pallene_tracer_errhandler"); /* -------- PALLENE TRACER CODE END -------- */ lua_pushcfunction(L, &pmain); /* to call 'pmain' in protected mode */ From b6c221d5bf0ca85df3f56f938af153368d0c089f Mon Sep 17 00:00:00 2001 From: SD Asif Hossein Date: Thu, 22 Aug 2024 03:03:50 +0600 Subject: [PATCH 2/2] Add clarification comments --- pt-lua.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pt-lua.c b/pt-lua.c index f65f4cf..f108de5 100644 --- a/pt-lua.c +++ b/pt-lua.c @@ -985,6 +985,7 @@ int main (int argc, char **argv) { lua_pop(L, 1); /* We do not need the finalizer object here */ /* supply the message handler function with custom tracebacks. */ + /* it is safe to set globals at this point, because no code has been run yet. */ lua_pushcfunction(L, msghandler); lua_setglobal(L, "pallene_tracer_errhandler"); /* -------- PALLENE TRACER CODE END -------- */