[Lldb-commits] [lldb] be18df3 - [lldb] Fix that SIGWINCH crashes IOHandlerEditline when we are not using the editline backend
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 19 10:14:34 PDT 2020
Author: Raphael Isemann
Date: 2020-06-19T19:14:16+02:00
New Revision: be18df3d23fe21fa622ec45fa09eddb3af3eef6b
URL: https://github.com/llvm/llvm-project/commit/be18df3d23fe21fa622ec45fa09eddb3af3eef6b
DIFF: https://github.com/llvm/llvm-project/commit/be18df3d23fe21fa622ec45fa09eddb3af3eef6b.diff
LOG: [lldb] Fix that SIGWINCH crashes IOHandlerEditline when we are not using the editline backend
Summary:
TerminalSizeChanged is called from our SIGWINCH signal handler but the
IOHandlerEditline currently doesn't check if we are actually using the real
editline backend. If we're not using the real editline backend, `m_editline_up`
won't be set and `IOHandlerEditline::TerminalSizeChanged` will access
the empty unique_ptr. In a real use case we don't use the editline backend
when we for example read input from a file. We also create some temporary
IOHandlerEditline's during LLDB startup it seems that are also treated
as non-interactive (apparently to read startup commands).
This patch just adds a nullptr check for`m_editline_up` as we do in the rest of
IOHandlerEditline.
Fixes rdar://problem/63921950
Reviewers: labath, friss
Reviewed By: friss
Subscribers: abidh, JDevlieghere
Differential Revision: https://reviews.llvm.org/D81729
Added:
lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
Modified:
lldb/source/Core/IOHandler.cpp
Removed:
################################################################################
diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index e29e70c030df..c8c5a52c4331 100644
--- a/lldb/source/Core/IOHandler.cpp
+++ b/lldb/source/Core/IOHandler.cpp
@@ -291,7 +291,8 @@ void IOHandlerEditline::Deactivate() {
void IOHandlerEditline::TerminalSizeChanged() {
#if LLDB_ENABLE_LIBEDIT
- m_editline_up->TerminalSizeChanged();
+ if (m_editline_up)
+ m_editline_up->TerminalSizeChanged();
#endif
}
diff --git a/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
new file mode 100644
index 000000000000..4a99ff6d0ead
--- /dev/null
+++ b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
@@ -0,0 +1,21 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @no_debug_info_test
+ def test_resize_no_editline(self):
+ """ Tests terminal resizing if the editline isn't used. """
+ dbg = lldb.SBDebugger.Create(False)
+ # Set the input handle to some stream so that we don't start the
+ # editline interface.
+ dbg.SetInputFileHandle(io.BytesIO(b""), True)
+ opts = lldb.SBCommandInterpreterRunOptions()
+ # Launch the command interpreter now.
+ dbg.RunCommandInterpreter(True, True, opts, 0, False, False)
+ # Try resizing the terminal which shouldn't crash.
+ dbg.SetTerminalWidth(47)
More information about the lldb-commits
mailing list