Fixes SEGFAUL in libbcc when actually setting a lost_cb
When setting a lost_cb, the reference to the ctypes function is not retained like the regular callback,
this leads to a SEGFAULT if the gc kills the lost_fn if a lost event occurs afterwards
@@ -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))
