[llvm-bugs] [Bug 39996] New: [DebugInfo] Sign-extended variable is described by smaller stack slot, resulting in parts being filled with garbage data

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 13 06:17:24 PST 2018


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

            Bug ID: 39996
           Summary: [DebugInfo] Sign-extended variable is described by
                    smaller stack slot, resulting in parts being filled
                    with garbage data
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: david.stenberg at ericsson.com
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

Reproduced on r348837.

Compiling the following file:

    #include <stdint.h>

    int g;

    __attribute__((noinline))
    void bar(int64_t a) {
      g = a; // Side effect to keep the call.
    }

    __attribute__((noinline))
    void foo(int32_t a, uint32_t b) {
      int64_t al = a;
      int64_t rl = 6;
      bar(al);
      bar(b);
    }

    int32_t value = -123;
    uint32_t junk = 0xcccccccc;

    int main() {
      foo(value, junk);
      return 0;
    }

using:

    $ clang -m32 -O3 -g foo.c -o foo.out

results in the 64-bit variable `al', which contains the sign-extended value of
`a', incorrectly being described by the stack slot for the 32-bit parameter
`a':

    0x000000d8:     DW_TAG_variable
                      DW_AT_location        (0x00000000
                         [0x0804838c,  0x08048394): DW_OP_breg4 ESP+16)
                      DW_AT_name    ("al")
                      DW_AT_decl_file       ("/path/to/foo.c")
                      DW_AT_decl_line       (12)
                      DW_AT_type    (0x000000fd "int64_t")

When printing the variable in LLDB and GDB, the 32 highest bits are printed by
using data from the second argument's stack slot:

    $ lldb-6.0 foo.out
    (lldb) target create "foo.out"
    Current executable set to 'foo.out' (i386).
    (lldb) b foo
    Breakpoint 1: where = foo.out`foo + 17 at foo.c:14, address = 0x08048391
    (lldb) run
    Process 992 launched: '/tmp/foo.out' (i386)
    Process 992 stopped
    * thread #1, name = 'foo.out', stop reason = breakpoint 1.1
        frame #0: 0x08048391 foo.out`foo(a=-123, b=3435973836) at foo.c:14
    (lldb) frame variable al -f hex
    (int64_t) al = 0xccccccccffffff85

-- 
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/20181213/e3a4d275/attachment-0001.html>


More information about the llvm-bugs mailing list