ktf icon indicating copy to clipboard operation
ktf copied to clipboard

memory leak when placing interceptions on specific functions

Open azulgrana13 opened this issue 7 years ago • 3 comments

Hi, Running KTF on my system (ubuntu 16.04) I've encountered some function for which the mere placement of the probes causes memory leaks. The memory coverage output is attached For now the function which caused it are:

  • register_oom_notifier
  • unregister_oom_notifier
  • file_open_root

The tests themselves are empty so I was able to isolate the problem:

KTF_RETURN_PROBE(register_oom_notifier, test_probe)
{
	return 0;
}

TEST(test_suite, lol)
{
	ASSERT_INT_EQ_GOTO(KTF_REGISTER_RETURN_PROBE(register_oom_notifier, test_probe),
			   0, done);
done:
	KTF_UNREGISTER_RETURN_PROBE(register_oom_notifier, test_probe);
}

ktf_memory_leak.txt

azulgrana13 avatar Aug 13 '18 15:08 azulgrana13

I think some information is missing here. There's no KTF_REGISTER_INTERCEPT operations in KTF?

knuto avatar Aug 14 '18 15:08 knuto

Sorry about the mix-up, we added a few macros in our project for our own comfort and I've forgot about them. I've edited the original comment with the code behind our macros.

azulgrana13 avatar Aug 14 '18 16:08 azulgrana13

thanks for reporting this issue! I think I may see the problem. It looks like you've enabled per-module coverage, and we have code that avoids memory tracking for the ktf_cov_kmem_cache_alloc_handler (so that we don't end up tracking the memory we use to track memory!), but I think we need to explicitly exclude ktf_cov_kmalloc_entry_handler too. I'll try to reproduce and spin up a fix.

alan-maguire avatar Nov 27 '18 10:11 alan-maguire