Commit b2f8db9c authored by 4ast's avatar 4ast Committed by GitHub

Merge pull request #1107 from Eichhoernchen/patch-1

Fixed SEGFAULT due to perf buffer overflow if lost_cb unset
parents d5e5bb3b b2d792cb
......@@ -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")
......@@ -533,7 +533,7 @@ class PerfEventArray(ArrayBase):
self[self.Key(cpu)] = self.Leaf(fd)
self.bpf._add_kprobe((id(self), cpu), reader)
# keep a refcnt
self._cbs[cpu] = fn
self._cbs[cpu] = (fn, lost_fn)
def close_perf_buffer(self, key):
reader = self.bpf.open_kprobes.get((id(self), key))
......
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