When shared libs were loaded via "set-dumpable libs", better release
them upon deinit, it will make valgrind happier. For this we now have
a new function free_collected_libs() in tools.c and call it in deinit().
void *get_sym_next_addr(const char *name);
int dump_libs(struct buffer *output, int with_addr);
void collect_libs(void);
+void free_collected_libs(void);
/* Note that this may result in opening libgcc() on first call, so it may need
* to have been called once before chrooting.
free(init_env);
}
free(progname);
-
+ free_collected_libs();
} /* end deinit() */
__attribute__((noreturn)) void deinit_and_exit(int status)
/* don't need the temporary storage anymore */
ha_free(&ctx.storage);
}
+
+/* release memory associated to collected libs */
+void free_collected_libs(void)
+{
+ if (!lib_storage || !lib_size)
+ return;
+ munmap(lib_storage, lib_size);
+ lib_storage = NULL;
+ lib_size = 0;
+}
+
# else // no DL_ITERATE_PHDR
# error "No dump_libs() function for this platform"
# endif
{
}
+/* unsupported platform: nothing to free */
+void free_collected_libs(void)
+{
+}
+
#endif // HA_HAVE_DUMP_LIBS
/*