The history_w() crashes when loading a history file (H_LOAD)
Status: Beta
Brought to you by:
thehobbit
I have faced that the LLDB crashes when loading a history file. The interesting thing that it happens in Terminal.app (on OS X) but it doesn't reproduce when I run LLDB remotely (via SSH on Windows).
LLDB does the following thing and looks like it's correct:
264 bool
265 Load ()
266 {
267 if (m_history)
268 {
269 const char *path = GetHistoryFilePath();
270 if (path)
271 {
272 history_w (m_history, &m_event, H_LOAD, path);
273 return true;
274 }
275 }
276 return false;
277 }
Nonetheless, it crashes and syslog shows the following reason:
[...]
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
[...]
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_c.dylib 0x00007fff80f43ca6 wcscmp + 8
1 libedit.3.dylib 0x000000010d6964f8 0x10d691000 + 21752
2 libedit.3.dylib 0x000000010d696f88 history_w + 2125
3 com.apple.LLDB.framework 0x000000010c540dbb lldb_private::line_editor::EditlineHistory::Load() + 53
[...]
I investigated my history file (which is located here: ~/.lldb/lldb-history). Initially it contained ~780 lines, but I found the one which causes it (see the last line):
$ cat ~/.lldb/lldb-history
_HiStOrY_V2_
\M-P\M-Pr\^J
I don't know what it means but I didn't touch that file. I suppose that LLDB flush'ed commands from my previous sessions but now it unable to parse them.
Test plan:
$ cat ~/.lldb/lldb-history
_HiStOrY_V2_
\M-P\M-Pr\^J
$ lldb
Segmentation fault: 11
$ mv ~/.lldb/lldb-history ~/.lldb/lldb-history1
$ cat ~/.lldb/lldb-history
cat: /Users/IliaK/.lldb/lldb-history: No such file or directory
$ lldb
(lldb) quit
$ mv ~/.lldb/lldb-history1 ~/.lldb/lldb-history
$ cat ~/.lldb/lldb-history
_HiStOrY_V2_
\M-P\M-Pr\^J
$ lldb
Segmentation fault: 11