llvm-project
llvm-project copied to clipboard
[clang/lldb] lldb wrongly stopped inside a dead loop
$ cat small.c
int main()
{
int j = 0, d = 0;
if (j>=0)
for (; d; d++)
return 0;
return 0;
}
$ clang --version
Ubuntu clang version 15.0.0-++20220520091548+a61835b1e3f5-1~exp1~20220520091641.498
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clang -O0 -g small.c; lldb a.out
(lldb) target create "a.out"
Current executable set to '/root/a.out' (x86_64).
(lldb) b 5
Breakpoint 1: where = a.out`main + 35 at small.c:5:5, address = 0x0000000000000623
(lldb) r
Process 20281 launched: '/root/a.out' (x86_64)
Process 20281 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000555555554623 a.out`main at small.c:5:5
2 {
3 int j = 0, d = 0;
4 if (j>=0)
-> 5 for (; d; d++)
6 return 0;
7 return 0;
8 }
(lldb) s
Process 20281 stopped
* thread #1, name = 'a.out', stop reason = step in
frame #0: 0x000055555555463e a.out`main at small.c:6:14
3 int j = 0, d = 0;
4 if (j>=0)
5 for (; d; d++)
-> 6 return 0;
7 return 0;
8 }
(lldb)
lldb wrongly stopped at line 6. However, d is 0 and lldb should not stopped inside the for loop.
I have report this bug in https://bugs.llvm.org/show_bug.cgi?id=45603 However, I found this problem is stilll in the latest version of clang/lldb.
@llvm/issue-subscribers-lldb
This issue was imported to Github as https://github.com/llvm/llvm-project/issues/44948