From: David VaĊĦek Date: Tue, 15 Jun 2021 19:50:49 +0000 (+0200) Subject: knotc: document a long-term memory leak in libedit2 library X-Git-Tag: v3.1.0~59^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bd040bfb56244cedd9e9fe9bfb33752bb31abec;p=thirdparty%2Fknot-dns.git knotc: document a long-term memory leak in libedit2 library There is a known memory leak in libedit2 library, when el_set() function is called with EL_ADDFN parameter. It has been known by the library author Christos Zoulas from the very beginning. The existence of the leak is already mentioned in the source code of the library: https://salsa.debian.org/debian/libedit/-/blob/master/src/eln.c#L226 The leak exists since the following commit to the library: http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/eln.c#rev1.4 There are hints that el_wset() doesn't suffer the same issue, so some prjects are moving to wide charecters in order to avoid this memory leak. https://reviews.llvm.org/rGc11e249bfdf406dc609048ca88af406007426630 [ LLDB is leaking memory in Editline.cpp on MacOSX. ] We are keeping Knot code as is for now. --- diff --git a/src/utils/knotc/interactive.c b/src/utils/knotc/interactive.c index d33f7f2c13..2d015e9102 100644 --- a/src/utils/knotc/interactive.c +++ b/src/utils/knotc/interactive.c @@ -392,6 +392,8 @@ int interactive_loop(params_t *process_params) el_set(el, EL_SIGNAL, 1); el_source(el, NULL); + // Warning: these two el_sets()'s always leak -- in libedit2 library! + // For more details see this commit's message. el_set(el, EL_ADDFN, PROGRAM_NAME"-complete", "Perform "PROGRAM_NAME" completion.", complete); el_set(el, EL_BIND, "^I", PROGRAM_NAME"-complete", NULL);