libbpfgo icon indicating copy to clipboard operation
libbpfgo copied to clipboard

Resource tracking

Open javierhonduco opened this issue 2 years ago • 1 comments

Something we have experienced in libbpfgo is that it's not hard to accidentally double-free resources (see this bug we recently hit https://github.com/parca-dev/parca-agent/pull/367 that ASAN catches https://github.com/parca-dev/parca-agent/pull/370), which beyond crashes, could have other implications.

Perhaps this could be avoided by having more checks in place to keep track of which resources are 'closed' or not. This would make the code less clean and maintainable and it won't be bulletproof 😢.

Just wanted to kickstart the discussion here, in case this is something any of you are interested in!

cc/ @rafaeldtinoco

javierhonduco avatar Apr 28 '22 15:04 javierhonduco

Thanks for opening this @javierhonduco and having a resource reference/usage status flag (or similar) sounds interesting indeed (not to close fds and/or double frees).

rafaeldtinoco avatar Apr 28 '22 15:04 rafaeldtinoco