Closed mdorier closed 5 months ago
Actually the process that leaks memory is whoever finalizes second. Here is an example where the child is the one finalizing second:
if(pid != 0) {
HG_Context_destroy(hg_context);
HG_Finalize(hg_class);
waitpid(pid, NULL, 0);
} else {
sleep(1);
HG_Context_destroy(hg_context);
HG_Finalize(hg_class);
}
I don't see anything being generated from asan on my machine... and I compiled mercury with CMAKE_BUILD_TYPE=Asan
Closing for now, please re-open if you see any more issues.
Describe the bug
I have a program that does a
fork()
after having initialized anhg_class
and anhg_context
(in the real scenario the child immediately destroys the class and context, before creating new ones that it can start using). When the parent destroys its class and context and terminates, with address sanitizer enabled, I see that it is leaking a bunch of things out of Mercury functions.To Reproduce
Here is an example code, to compile with
CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
andLDFLAGS="-fsanitize=address -fno-omit-frame-pointer"
:If you run with
ASAN_OPTIONS="log_path=asan.log"
you will get anasan.log.XXXX
file whereXXXX
is the pid of the parent (the child doesn't seem to be leaking memory, but if you want to confirm that, simply add anelse
clause for the child and make it segfault, you will end up with anotherasan.log.YYYY
for it).Expected behavior
I would expect Mercury not to leak memory.
Platform (please complete the following information):