[all-commits] [llvm/llvm-project] ffcf57: [LLDB] Fix 'std::out_of_range' crashing bug when f...

iam-i via All-commits all-commits at lists.llvm.org
Mon Aug 30 06:14:33 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ffcf571107594ff5d02bc2410266efe527787fb0
      https://github.com/llvm/llvm-project/commit/ffcf571107594ff5d02bc2410266efe527787fb0
  Author: Hiroki <h.imai.833 at nitech.jp>
  Date:   2021-08-30 (Mon, 30 Aug 2021)

  Changed paths:
    M lldb/source/Host/common/Editline.cpp
    A lldb/test/API/iohandler/completion/Makefile
    M lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py

  Log Message:
  -----------
  [LLDB] Fix 'std::out_of_range' crashing bug when file name completion using file path.

When I run a lldb command that uses filename completion, if I enter a string
that is not only a filename but also a string with a non-file name string added,
such as "./" that is relative path string , it will crash as soon as I press the
[Tab] key. For example, debugging an executable file named "hello" that is
compiled from a file named "hello.c" , and I’ll put a breakpoint on line 3 of
hello.c.

```
$ lldb ./hello
(lldb) breakpoint set --file hello.c --line 3
```

This is not a problem, but if I set "--file ./hello."  and then press [Tab] key
to complete file name, lldb crashes.

```
$ lldb ./hello
(lldb) breakpoint set --file ./hello.terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 8) > this->size() (which is 7)
```

The crash was caused because substr() (in lldb/source/Host/common/Editline.cpp)
cut out string which size is user's input string from the completion string.

I modified the code that erase the user's intput string from current line and
then add the completion string.

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




More information about the All-commits mailing list