bcc icon indicating copy to clipboard operation
bcc copied to clipboard

memleak: 'list' object has no attribute 'decode'

Open selfboot opened this issue 2 years ago • 0 comments

Run: memleak.py -p 38521 --combined-only Get the following exception:

Traceback (most recent call last):
  File "/usr/local/drop/tools/ebpf/memleak.py", line 573, in <module>
    print_outstanding_combined()
  File "/usr/local/drop/tools/ebpf/memleak.py", line 546, in print_outstanding_combined
    trace = "\n\t\t".join(trace.decode())
AttributeError: 'list' object has no attribute 'decode'

The corresponding code:

def print_outstanding_combined():
        stack_traces = bpf["stack_traces"]
        stacks = sorted(bpf["combined_allocs"].items(),
                        key=lambda a: -a[1].total_size)
        cnt = 1
        entries = []
        for stack_id, info in stacks:
                try:
                        trace = []
                        for addr in stack_traces.walk(stack_id.value):
                                sym = bpf.sym(addr, pid,
                                                      show_module=True,
                                                      show_offset=True)
                                trace.append(sym)
                        trace = "\n\t\t".join(trace.decode())
                        // seems should be: trace = "\n\t\t".join(trace)
                except KeyError:
                        trace = "stack information lost"

                entry = ("\t%d bytes in %d allocations from stack\n\t\t%s" %
                         (info.total_size, info.number_of_allocs, trace))
                entries.append(entry)

                cnt += 1
                if cnt > top_stacks:
                        break

        print("[%s] Top %d stacks with outstanding allocations:" %
              (datetime.now().strftime("%H:%M:%S"), top_stacks))

        print('\n'.join(reversed(entries)))

selfboot avatar Oct 18 '23 07:10 selfboot