[llvm-bugs] [Bug 50327] New: Incorrect call frame info on X86_64 target

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 13 05:37:24 PDT 2021


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

            Bug ID: 50327
           Summary: Incorrect call frame info on X86_64 target
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: djordje.todorovic at syrmia.com
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

$ cat test.c
#include <stdlib.h>

int f2(char *input) { return crasher(input, 1); }
int crasher(char *input, int crash) {
  if (crash)
    input = NULL;
  input[0] = '1';
  input[1] = '2';
  input[2] = '3';
  input[3] = '\0';
  f2(input);
  if (crash)
    return 0;
  else
    return 1;
}

int f1() {
  char *input = (char *)malloc(sizeof(char) * 10);
  return crasher(input, 0);
}
int main(int argc, char **argv) {
  f1();
  return 0;
}

This small example when compiled with -O1 produces call frame info that causes
incorrect backtrace in GDB.

$ clang -O1 test.c -o test
$ ./test
Segmentation fault (core dumped)
$ lldb test -c core.test
...
(lldb) bt
* thread #1, name = 'test', stop reason = signal SIGSEGV
  * frame #0: 0x0000000000401156 test`f2 + 6
    frame #1: 0x000000000040116c test`crasher + 12
    frame #2: 0x000000000040115b test`f2 + 11
    frame #3: 0x000000000040116c test`crasher + 12
    frame #4: 0x000000000040115b test`f2 + 11
    frame #5: 0x000000000040116c test`crasher + 12
    frame #6: 0x000000000040115b test`f2 + 11
    frame #7: 0x000000000040116c test`crasher + 12
    frame #8: 0x000000000040115b test`f2 + 11
    frame #9: 0x000000000040116c test`crasher + 12
    frame #10: 0x000000000040115b test`f2 + 11
    frame #11: 0x000000000040116c test`crasher + 12
    frame #12: 0x000000000040115b test`f2 + 11
    frame #13: 0x000000000040116c test`crasher + 12
...

With gcc, it looks ok:
$ gcc -O1 test.c -o test-gcc
$ ./test-gcc
Segmentation fault (core dumped)
$ lldb ./test-gcc -c core.test-gcc
...
(lldb) bt
* thread #1, name = 'test-gcc', stop reason = signal SIGSEGV
  * frame #0: 0x000000000040115b test-gcc`crasher + 14
    frame #1: 0x000000000040118c test-gcc`f2 + 19
    frame #2: 0x000000000040116f test-gcc`crasher + 34
    frame #3: 0x00000000004011ac test-gcc`f1 + 27
    frame #4: 0x00000000004011bf test-gcc`main + 14
    frame #5: 0x00007fea1df1c555 libc.so.6`__libc_start_main + 245
    frame #6: 0x0000000000401089 test-gcc`_start + 41


This has been reproduced with x86_64 GNU/Linux platform.

-- 
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/20210513/309d1527/attachment.html>


More information about the llvm-bugs mailing list