Editline: Fix an msan error
authorPavel Labath <pavel@labath.sk>
Mon, 29 Apr 2019 13:54:12 +0000 (13:54 +0000)
committerPavel Labath <pavel@labath.sk>
Mon, 29 Apr 2019 13:54:12 +0000 (13:54 +0000)
Summary:
libedit implementation of el_get(EL_GETTC) had a bug, where it was
consuming vararg arguments until reaching the first null pointer (and
not just two, as documented). This was causing (at least) errors to be
reported when running the tests under msan.

The issue has since been fixed in libedit, but this adds patch adds a
trivial workaround, so that we operate correctly with the libedit
versions which are already out there.

Reviewers: christos, krytarowski, davide

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D61191

llvm-svn: 359449

lldb/source/Host/common/Editline.cpp

index c9cc5c0..da83de6 100644 (file)
@@ -1215,9 +1215,13 @@ void Editline::TerminalSizeChanged() {
   if (m_editline != nullptr) {
     el_resize(m_editline);
     int columns;
-    // Despite the man page claiming non-zero indicates success, it's actually
-    // zero
-    if (el_get(m_editline, EL_GETTC, "co", &columns) == 0) {
+    // This function is documenting as taking (const char *, void *) for the
+    // vararg part, but in reality in was consuming arguments until the first
+    // null pointer. This was fixed in libedit in April 2019
+    // <http://mail-index.netbsd.org/source-changes/2019/04/26/msg105454.html>,
+    // but we're keeping the workaround until a version with that fix is more
+    // widely available.
+    if (el_get(m_editline, EL_GETTC, "co", &columns, nullptr) == 0) {
       m_terminal_width = columns;
       if (m_current_line_rows != -1) {
         const LineInfoW *info = el_wline(m_editline);