]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: debug/lua: Don't dump the lua stack if not dumpable
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 19 Mar 2021 14:41:08 +0000 (15:41 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 19 Mar 2021 15:19:59 +0000 (16:19 +0100)
When we try to dump the stack of a lua context, if it is not dumpable,
nothing is performed and a message is emitted instead. This happens when a
lua execution was interrupted inside a non-reentrant part.

This patch depends on following commit :

 * MEDIUM: lua: Use a per-thread counter to track some non-reentrant parts of lua

Thanks to this patch, we avoid a possible deadllock if the lua is
interrupted by the watchdog in the lua memory allocator, because realloc()
is not async-signal-safe.

Both patches must be backported as far as 2.0.

src/debug.c

index f86d05490515934cf5ea456353aae9a08dce09ba..9346828577beb7422433fdf0e83e320d57b42b48 100644 (file)
@@ -264,9 +264,13 @@ 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');
+               if (hlua_not_dumpable == 0) {
+                       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');
+               }
+               else
+                       chunk_appendf(buf, "Inside non-rentrant part, Stack traceback not available\n");
        }
        else
                b_putchr(buf, '\n');