[LLVMbugs] [Bug 17635] New: possible wrongful crash from undefined sanitizer

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Oct 21 08:59:27 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=17635

            Bug ID: 17635
           Summary: possible wrongful crash from undefined sanitizer
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: regehr at cs.utah.edu
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I can't see anything wrong with the code below yet it throws an illegal
instruction.  Note that the packed and unpacked structs have the same field
offsets in 32-bit mode.

$ clang -m32 -O -fsanitize=undefined main.c ; ./a.out 
24 23
Illegal instruction

$ cat main.c
#include <stdio.h>
#include <assert.h>

struct s2 {
  long long f0;
  long f1;
  unsigned int f2;
  unsigned long f3;
  short f4;
  unsigned char f5;
};

#pragma pack (1)
struct s2_packed {
  long long f0;
  long f1;
  unsigned int f2;
  unsigned long f3;
  short f4;
  unsigned char f5;
};
#pragma pack ()

void copy (char* out, char* in)
{
  int i;
  for (i = 0; i < 23; i++) out[i] = in[i];
}

int main (void)
{
  struct s2 topack1 = {48098, 3948348, 234985, 32034849, 3432, 'u'};
  struct s2_packed packed1;
  printf ("%d %d\n", sizeof (struct s2), sizeof (struct s2_packed));
  copy((char*)&packed1, (char*)&topack1);
  assert(topack1.f0 == packed1.f0);
  assert(topack1.f1 == packed1.f1);
  assert(topack1.f2 == packed1.f2);
  assert(topack1.f3 == packed1.f3);
  assert(topack1.f4 == packed1.f4);
  assert(topack1.f5 == packed1.f5);
  printf("Tests Complete.\n");
  return 0;
}

$ clang -v
clang version 3.4 (trunk 193086)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7

-- 
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/20131021/fc7cf288/attachment.html>


More information about the llvm-bugs mailing list