[PATCH] Fixing a crashing bug in multiword commands

Hi everyone,

Currently, this is the output from a LLDB session:

[3:21pm][wlynch@orange bin] ./lldb
(lldb) process
terminate called after throwing an instance of ‘std::logic_error’
what(): basic_string::_S_construct NULL not valid

If the attached patch is applied, the following is the LLDB session:

[3:25pm][wlynch@orange bin] ./lldb

(lldb) process
The following subcommands are supported:

attach – Attaches to a process.
continue – Continues execution all threads in the current process.
detach – Detaches from the current process being debugged.
interrupt – Interrupts the current process being debugged.
kill – Terminates the current process being debugged.
launch – Launches the executable in the debugger.
signal – Sends a UNIX signal to the current process being debugged.
status – Shows the current status and location of executing process.

For more help on any particular subcommand, type ‘help ’.

Here’s some notes on what’s going on:

So, “process” is a multiword command object. That is, it uses CommandObjectMultiword to choose between a set of possible classes. In CommandObjectMultiword, a map is created to search for the desired subcommand. If null is searched for in that map, an uncaught exception is thrown by the standard library. Basically, it calls std::string(NULL).

The fix for this is to make sure that when we look for the next subcommand, to verify that one does in fact exist.

And here’s the patch:

Index: source/Commands/CommandObjectMultiword.cpp

Committed revision 108958.