This is https://bugs.llvm.org/show_bug.cgi?id=40112,
Currently, lldb crashes after pressing the up arrow key when listing the history for expressions.
The patch fixes the mistype that was a reason.
Differential D56014
[lldb] - Fix crash when listing the history with the key up. grimar on Dec 21 2018, 10:53 AM. Authored by
Details This is https://bugs.llvm.org/show_bug.cgi?id=40112, Currently, lldb crashes after pressing the up arrow key when listing the history for expressions. The patch fixes the mistype that was a reason.
Diff Detail
Event TimelineComment Actions I investigated how to add it and I do not see a good way write a test :( Seems the proper place to test it would be unittest/Editline: It allows to send the text using the virtual terminal: And I was able to simulate the key up press ("lldb-previous-line" command) sending the "\x1b[A" line But this is not enough. Case fixed by this patch assumes that some expression history exists. I am not sure it is a good idea to export it for the unit test. I do not think it is correct Given all above it seems it is really problematic to write a test for this now. Comment Actions I guess it should be possible to trigger this from dotest tests via pexpect. I know we try to avoid it, but given that this is specifically testing terminal interaction, using it here seems appropriate. Comment Actions Thanks for the suggestion. I'll try to investigate it and return with the results during the next week I guess. Comment Actions I ended up with the following test case: TestHistoryCrash.py: """We crashed when navigated through the history. Check we do not now.""" from __future__ import print_function import os import sys import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import configuration from lldbsuite.test import lldbutil class TestNoCrashForHistoryRecall(TestBase): mydir = TestBase.compute_mydir(__file__) # If your test case doesn't stress debug info, the # set this to true. That way it won't be run once for # each debug info format. NO_DEBUG_INFO_TESTCASE = True def setUp(self): TestBase.setUp(self) @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") def test_history_recall(self): self.child_prompt = '(lldb) ' self.sample_test() def sample_test(self): import pexpect self.child = pexpect.spawn( '%s %s' % (lldbtest_config.lldbExec, self.lldbOption)) child = self.child child.sendline('print') child.expect_exact('Enter expressions') child.sendline('\x1b[A') child.close() self.assertEqual(child.exitstatus, 0) It works, but not in all cases. Problem is that history patch is hardcoded and history is stored in the home directory (~/.lldb/lldb-expr-history): When the history file exists and is empty (has a header, but no history lines), the test case can trigger the crash successfully. It is not a good idea to touch or modify files outside the build folder from the test, so that does not seem what I can change. Given above I suggest going without a test, perhaps. Comment Actions Although I don't want to condone checking things in without a test case, given that the fix is obvious and that testing it is non-trivial, I think it's fine to check this in as is. |