openresty/openresty-systemtap-toolkit

ngx-sample-lua-bt collects fragments of /lua/5.1/json/encode/object.lua

zharan opened this issue · 1 comments

Hi,

After running the following command:

sudo ./ngx-sample-lua-bt -p 25192 --lua51 -t 30 > tmp12.bt

I noticed fragments of code from /usr/local/share/lua/5.1/json/encode/object.lua in tmp12.bt:

<fragment begin>
        29
@/usr/local/share/lua/5.1/json/encode.lua:84
[tail]
            return function(composite, ret, encode, state)
            local first = true
    for k, v in pairs(composite) do
            local ti = type(k)
            assert(ti == 'string' or ti == 'number' or ti == 'boolean', "Invalid object index type: " .. ti)
            local name = encode(tostring(k), state, true)
            if first then
                    first = false
            else
                    name = ',' .. name
            end
                    ret[#ret + 1] = (name .. ':')

            local val = encode(v, state)
            val = val or ''
            if val then
                            ret[#ret + 1] = (val)

            end
    end
                    end
    :1
@/usr/local/share/lua/5.1/json/encode/output.lua:31
<fragment end>

As a result I get malformed svg file after converting tmp12.bt into a flame-graph. What problem could this be?

@zharan This happens when the chunk name is the source itself (like loaded by the Lua builtin loadstring without specifying a chunk name). Better explicitly provide a chunk name to the loadstring builtin. Another option is to make sample-lua-bt remove newlines and other special chars from this long chunk name.