[llvm-bugs] [Bug 44585] New: Incorrect DWARF expressions produced with SafeStack

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 17 09:56:56 PST 2020


            Bug ID: 44585
           Summary: Incorrect DWARF expressions produced with SafeStack
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: leonardchan at google.com
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

Given the following snippet:

#include <stdio.h>
#include <string>

int main(int argc, char* argv[]) {
  std::string value = "asdf";
  printf("%s\n", value.c_str());
  return 0;

And compiling with (tip of tree) clang: `clang++ -g -fsanitize=safe-stack
/tmp/test.cpp`, we are unable to identify symbols:

$ gdb a.out
(gdb) start
5           int main(int argc, char* argv[]) {
(gdb) n
6             std::string value = "asdf";
7             printf("%s\n", value.c_str());
(gdb) p value
Cannot access memory at address 0x1

We can assert `p value` prints "asdf" when compiling without SafeStack. A
dwarfdump shows that "value" looks like:

0x00001ab0:     DW_TAG_variable
                  DW_AT_location        (0x00000000: 
                     [0x0000000000000013, 0x000000000000003a): DW_OP_breg2
                     [0x000000000000003a, 0x0000000000000128): DW_OP_breg6
RBP-40, DW_OP_constu 0x20, DW_OP_minus, DW_OP_deref)
                  DW_AT_name    ("value")
                  DW_AT_decl_file       ("/tmp/test.cpp")
                  DW_AT_decl_line       (5)
                  DW_AT_type    (0x00000741 "string")

The `DW_OP_breg2 RCX-32` seems correct, but the `DW_OP_breg6 RBP-40,
DW_OP_constu 0x20, DW_OP_minus, DW_OP_deref` should be something like
`DW_OP_breg6 RBP-40, DW_OP_deref, DW_OP_constu 0x20, DW_OP_minus` to reflect:

movq    -40(%rbp), %rax
addq    $-40, %rax

A bisect was able to determine that https://reviews.llvm.org/D68945 introduced
this bug. The issue was initially addressed in https://reviews.llvm.org/D65172
but was re-introduced.

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/20200117/1bff8d4b/attachment-0001.html>

More information about the llvm-bugs mailing list