]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
knotc: document a long-term memory leak in libedit2 library
authorDavid Vašek <david.vasek@nic.cz>
Tue, 15 Jun 2021 19:50:49 +0000 (21:50 +0200)
committerDavid Vašek <david.vasek@nic.cz>
Fri, 18 Jun 2021 09:11:32 +0000 (11:11 +0200)
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.

src/utils/knotc/interactive.c

index d33f7f2c137c328c9475e940ee213fe7e76ab5d5..2d015e910222610cc062e977f174b8a7af94735a 100644 (file)
@@ -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);