]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hlua: don't dump empty entries in hlua_traceback()
authorWilly Tarreau <w@1wt.eu>
Sun, 19 Jun 2022 15:35:53 +0000 (17:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 19 Jun 2022 15:58:32 +0000 (17:58 +0200)
Calling hlua_traceback() sometimes reports empty entries looking like:

   [C]: ?

These ones correspond to certain internal C functions of the Lua library,
but they do not provide any information and even complicate the
interpretation of the dump. Better just skip them.

src/hlua.c

index 33f054db57fee42fd38da9a1a0da7a4a745db2e0..0959be51cc14e166ab62125ed0b477a44c146875 100644 (file)
@@ -505,11 +505,6 @@ __LJMP const char *hlua_traceback(lua_State *L, const char* sep)
        struct buffer *msg = get_trash_chunk();
 
        while (lua_getstack(L, level++, &ar)) {
-
-               /* Add separator */
-               if (b_data(msg))
-                       chunk_appendf(msg, "%s", sep);
-
                /* Fill fields:
                 * 'S': fills in the fields source, short_src, linedefined, lastlinedefined, and what;
                 * 'l': fills in the field currentline;
@@ -518,6 +513,14 @@ __LJMP const char *hlua_traceback(lua_State *L, const char* sep)
                 */
                lua_getinfo(L, "Slnt", &ar);
 
+               /* skip these empty entries, usually they come from deep C functions */
+               if (ar.currentline < 0 && *ar.what == 'C' && !*ar.namewhat && !ar.name)
+                       continue;
+
+               /* Add separator */
+               if (b_data(msg))
+                       chunk_appendf(msg, "%s", sep);
+
                /* Append code localisation */
                if (ar.currentline > 0)
                        chunk_appendf(msg, "%s:%d: ", ar.short_src, ar.currentline);