[llvm-bugs] [Bug 46038] New: Wrong backtrace information at O3

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 22 06:56:57 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46038

            Bug ID: 46038
           Summary: Wrong backtrace information at O3
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: massarelli at diag.uniroma1.it
                CC: ditaliano at apple.com, jdevlieghere at apple.com,
                    keith.walker at arm.com, llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

At some point on line 18 (for (; h < 6; h++)) the backtrace information is
totally wrong.

$ cat a.c
char a, d;
int b, f, g, h;
char c[1][1];
short e, l;
static const unsigned m(unsigned, unsigned char);
static int n() { return e; }
static unsigned short o(unsigned);
static short p() { m(d, a); }
const unsigned m(unsigned q, unsigned char r) {
  f = n();
  o(r);
  g = q;
}
unsigned short o(unsigned q) {
  int s[6][10] = {5, 5, 1, 5, 5, 3, 6};
  b = s[4][9] & q;
  h = 0;
  for (; h < 6; h++)
    for (; l < 0; l++)
      s[h][l] = 9;
}
int main() {
  int i, j, k;
  p();
  i = 0;
  for (; i < 10; i++) {
    j = 0;
    for (; j < 4; j++) {
      k = 0;
      for (; k < 4; k++)
        printf("%d\n", c[j]);
    }
  }
}

$ clang -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
da52aa2c3340d91025c0188175012c476967dc74)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ lldb -v
lldb version 11.0.0
clang revision da52aa2c3340d91025c0188175012c476967dc74
llvm revision da52aa2c3340d91025c0188175012c476967dc74

$ clang -Og -g -o opt a.c

$ lldb opt 
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b -l 18
Breakpoint 1: where = opt`o + 64 at amod.c:18:18, address = 0x0000000000400640
(lldb) r
Process 599 launched: 'opt' (x86_64)
Process 599 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400640 opt`o(q=4294960048) at amod.c:18:18
   15     int s[6][10] = {5, 5, 1, 5, 5, 3, 6};
   16     b = s[4][9] & q;
   17     h = 0;
-> 18     for (; h < 6; h++)
   19       for (; l < 0; l++)
   20         s[h][l] = 9;
   21   }
(lldb) c -i 4 
Process 599 resuming
Process 599 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400640 opt`o(q=4294960048) at amod.c:18:18
   15     int s[6][10] = {5, 5, 1, 5, 5, 3, 6};
   16     b = s[4][9] & q;
   17     h = 0;
-> 18     for (; h < 6; h++)
   19       for (; l < 0; l++)
   20         s[h][l] = 9;
   21   }
(lldb) bt
* thread #1, name = 'opt', stop reason = breakpoint 1.1
  * frame #0: 0x0000000000400640 opt`o(q=4294960048) at amod.c:18:18
    frame #1: 0x00000000004005e9 opt`m(q=0, r=<unavailable>) at amod.c:11:3
    frame #2: 0x00000000004005c4 opt`p at amod.c:8:20
    frame #3: 0x000000000040054c opt`main at amod.c:24:3
    frame #4: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
    frame #5: 0x000000000040047a opt`_start + 42
(lldb) s
Process 599 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x000000000040064c opt`o(q=4294960048) at amod.c:18:3
   15     int s[6][10] = {5, 5, 1, 5, 5, 3, 6};
   16     b = s[4][9] & q;
   17     h = 0;
-> 18     for (; h < 6; h++)
   19       for (; l < 0; l++)
   20         s[h][l] = 9;
   21   }
(lldb) bt
* thread #1, name = 'opt', stop reason = step in
  * frame #0: 0x000000000040064c opt`o(q=4294960048) at amod.c:18:3
    frame #1: 0x0000000004e56c72
    frame #2: 0x00007ffff7b7e0b0
libc.so.6`___lldb_unnamed_symbol1008$$libc.so.6 + 672
    frame #3: 0x00007ffff7b7e6a0
libc.so.6`___lldb_unnamed_symbol1019$$libc.so.6 + 64
    frame #4: 0x00007ffff7b80670 libc.so.6
    frame #5: 0x00007ffff7b7e810 libc.so.6
    frame #6: 0x00007ffff7b7e850
libc.so.6`___lldb_unnamed_symbol1023$$libc.so.6 + 64
    frame #7: 0x00007ffff7b7e8b0
libc.so.6`___lldb_unnamed_symbol1024$$libc.so.6 + 96
    frame #8: 0x00007ffff7b00de0 libc.so.6
    frame #9: 0x00007ffff7b7e930
libc.so.6`___lldb_unnamed_symbol1026$$libc.so.6 + 16
    frame #10: 0x00007ffff7b7e960
libc.so.6`___lldb_unnamed_symbol1027$$libc.so.6 + 48
    frame #11: 0x00007ffff7b7ea30
libc.so.6`___lldb_unnamed_symbol1028$$libc.so.6 + 208
    frame #12: 0x00007ffff7b80680
libc.so.6`___lldb_unnamed_symbol1043$$libc.so.6 + 16
    frame #13: 0x00007ffff7b80750
libc.so.6`___lldb_unnamed_symbol1044$$libc.so.6 + 208
    frame #14: 0x00007ffff7b807e0
libc.so.6`___lldb_unnamed_symbol1045$$libc.so.6 + 144
    frame #15: 0x00007ffff7b7ece0
libc.so.6`___lldb_unnamed_symbol1034$$libc.so.6 + 48
    frame #16: 0x00007ffff7b7ed10
libc.so.6`___lldb_unnamed_symbol1035$$libc.so.6 + 48
    frame #17: 0x00007ffff7b7ed40
libc.so.6`___lldb_unnamed_symbol1036$$libc.so.6 + 48
    frame #18: 0x00007ffff7b7ed70
libc.so.6`___lldb_unnamed_symbol1037$$libc.so.6 + 48
    frame #19: 0x00007ffff7b7eda0
libc.so.6`___lldb_unnamed_symbol1038$$libc.so.6 + 48
    frame #20: 0x00007ffff7b7eeb0
libc.so.6`___lldb_unnamed_symbol1040$$libc.so.6 + 224
    frame #21: 0x00007ffff7b80680
libc.so.6`___lldb_unnamed_symbol1043$$libc.so.6 + 16
    frame #22: 0x00007ffff7b807e0
libc.so.6`___lldb_unnamed_symbol1045$$libc.so.6 + 144

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200522/f25faba5/attachment.html>


More information about the llvm-bugs mailing list