[llvm-bugs] [Bug 40510] New: kmsan: false negative on bitfields

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 29 01:18:18 PST 2019


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

            Bug ID: 40510
           Summary: kmsan: false negative on bitfields
           Product: compiler-rt
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: compiler-rt
          Assignee: unassignedbugs at nondot.org
          Reporter: dvyukov at google.com
                CC: llvm-bugs at lists.llvm.org

clang version 8.0.0 (trunk 350842)

struct A {
        int a:1;
        int b:1;
        int c:1;
        int d:1;
        int e:1;
};

A* newA()
{
        A* a = new A;
        a->c = 0;
        a->d = 1;
        return a;
}

#include <stdio.h>

int main()
{
        volatile A* volatile a = newA();
        if (a->b)
                printf("1\n");
        return 0;
}


clang++ /tmp/init.cc -O2 -fsanitize=memory -g && ./a.out

Does not report the use of uninit.
Generated code initializes whole shadow to 0:

0000000000000000 <_Z4newAv>:
   0:   53                      push   %rbx
   1:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 8 <_Z4newAv+0x8>
   8:   64 48 c7 00 00 00 00    movq   $0x0,%fs:(%rax)
   f:   00 
  10:   48 8b 1d 00 00 00 00    mov    0x0(%rip),%rbx        # 17
<_Z4newAv+0x17>
  17:   64 48 c7 03 00 00 00    movq   $0x0,%fs:(%rbx)
  1e:   00 
  1f:   bf 04 00 00 00          mov    $0x4,%edi
  24:   e8 00 00 00 00          callq  29 <_Z4newAv+0x29>
  29:   48 b9 00 00 00 00 00    movabs $0x500000000000,%rcx
  30:   50 00 00 
  33:   48 31 c1                xor    %rax,%rcx
  36:   c6 01 00                movb   $0x0,(%rcx)
  39:   c6 00 08                movb   $0x8,(%rax)
  3c:   64 48 c7 03 00 00 00    movq   $0x0,%fs:(%rbx)
  43:   00 
  44:   5b                      pop    %rbx
  45:   c3                      retq

-- 
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/20190129/089cea8b/attachment.html>


More information about the llvm-bugs mailing list