Commit 784057b1 authored by Jan's avatar Jan Committed by GitHub

Fixed SEGFAULT due to perf buffer overflow if lost_cb unset

This fixes a SEGFAULT in the underlying libbcc when no lost_cb is set.
This occurs when the perf buffer is full and the lost_cb is called.
libbcc expects a NULL pointer as lost_cb to trigger its internal lost message.
This fixes the bug by providing an appropriate NULL pointer when lost_cb is unset.
parent d5e5bb3b
......@@ -525,7 +525,7 @@ class PerfEventArray(ArrayBase):
def _open_perf_buffer(self, cpu, callback, page_cnt, lost_cb):
fn = _RAW_CB_TYPE(lambda _, data, size: callback(cpu, data, size))
lost_fn = _LOST_CB_TYPE(lambda lost: lost_cb(lost) if lost_cb else -1)
lost_fn = _LOST_CB_TYPE(lambda lost: lost_cb(lost)) if lost_cb else ct.cast(None, _LOST_CB_TYPE)
reader = lib.bpf_open_perf_buffer(fn, lost_fn, None, -1, cpu, page_cnt)
if not reader:
raise Exception("Could not open perf buffer")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment