-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(libsinsp): memleak in sinsp_dns_manager #1526
Conversation
LeakSanitizer: detected memory leaks Direct leak of 8 byte(s) in 1 object(s) allocated from: ... 0x7f84317d54c8 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:95 ... 0x56319abb44cc in sinsp_dns_manager::match(char const*, int, void*, unsigned long) /build/falcosecurity-libs-repo/falcosecurity-libs-prefix/src/falcosecurity-libs/userspace/libsinsp/dns_manager.cpp:121 add destructor to class sinsp_dns_manager to ensure m_resolver is always released when the object goes out of scope Signed-off-by: Melissa Kilby <[email protected]>
/milestone 0.14.0 |
void operator=(sinsp_dns_manager const&) = delete; | ||
|
||
~sinsp_dns_manager() { | ||
cleanup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: cleanup
is idempotent:
void sinsp_dns_manager::cleanup()
{
if(m_resolver)
{
m_exit_signal.set_value();
m_resolver->join();
m_resolver = NULL;
m_exit_signal = std::promise<void>();
}
}
LGTM :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
LGTM label has been added. Git tree hash: 984e60622905122157088003245a4b0da520ca9d
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP, incertum, LucaGuerra The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@LucaGuerra @FedeDP and @federico-sysdig while it appeared to make sense adding the destructor I am still seeing the memleak. Seems like we need to invest more and actually look into this more thoroughly and add a test so we check it with asan in the CI. |
@incertum I'm not sure if I can be of great help here... The only thing I find odd is keeping the thread as a pointer and, on top of that, never deleting it. I'd change the thread data member as a normal |
SGTM and like a great improvement regardless. Do you want to author the PR? Thanks in advance 🙏 ! |
@incertum Feel free to proceed as you wish. It's a small thing. Thanks for asking. |
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area libsinsp
Does this PR require a change in the driver versions?
What this PR does / why we need it:
LeakSanitizer: detected memory leaks
Direct leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x7f84317d54c8 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:95
#1 0x56319abb44cc in sinsp_dns_manager::match(char const*, int, void*, unsigned long) /build/falcosecurity-libs-repo/falcosecurity-libs-prefix/src/falcosecurity-libs/userspace/libsinsp/dns_manager.cpp:121
add destructor to class sinsp_dns_manager to ensure m_resolver is always released when the object goes out of scope
@LucaGuerra
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: