iovisor / iovisor/bcc

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

Open
#4,767 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
22.7k
Forks
4.1k
Avg merge
10d 4h
Merged PRs (30d)
3

Description

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
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)))
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in tools/ebpf/memleak.py at print_outstanding_combined() and inspect how stack_traces.walk() and bpf.sym() build trace. Run memleak.py -p 38521 --combined-only and verify the command prints outstanding stack information without the AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability-sre
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.