From a6a8692142dd3804c524406e544cc22a8c19623c Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 24 Mar 2021 14:52:24 +0100 Subject: [PATCH] BUG/MEDIUM: debug/lua: Use internal hlua function to dump the lua traceback The commit reverts following commits: * 83926a04 BUG/MEDIUM: debug/lua: Don't dump the lua stack if not dumpable * a61789a1 MEDIUM: lua: Use a per-thread counter to track some non-reentrant parts of lua Instead of relying on a Lua function to print the lua traceback into the debugger, we are now using our own internal function (hlua_traceback()). This one does not allocate memory and use a chunk instead. This avoids any issue with a possible deadlock in the memory allocator because the thread processing was interrupted during a memory allocation. This patch relies on the commit "BUG/MEDIUM: debug/lua: Use internal hlua function to dump the lua traceback". Both must be backported wherever the patches above are backported, thus as far as 2.0 (cherry picked from commit cc2c4f8f4c1d8613b481d1b346e083a9d2462811) Signed-off-by: Christopher Faulet (cherry picked from commit 9fb7eb90289552de9de544412de3f178cf6a3723) Signed-off-by: Christopher Faulet (cherry picked from commit f80140db77075d3dcca673c8a58ea23468676114) [wt: minor context adjustment: older attempt was not there in 2.1] Signed-off-by: Willy Tarreau --- src/debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/debug.c b/src/debug.c index 75ca45a..6a18872 100644 --- a/src/debug.c +++ b/src/debug.c @@ -219,9 +219,9 @@ void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx) } if (hlua && hlua->T) { - luaL_traceback(hlua->T, hlua->T, NULL, 0); - if (!append_prefixed_str(buf, lua_tostring(hlua->T, -1), pfx, '\n', 1)) - b_putchr(buf, '\n'); + chunk_appendf(buf, "stack traceback:\n "); + append_prefixed_str(buf, hlua_traceback(hlua->T, "\n "), pfx, '\n', 0); + b_putchr(buf, '\n'); } else b_putchr(buf, '\n'); -- 1.7.10.4