[llvm-bugs] [Bug 32700] New: odr-violation and, if ignored, SEGV when using ASAN on code emitted from -emit-llvm

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 18 05:21:42 PDT 2017


            Bug ID: 32700
           Summary: odr-violation and, if ignored, SEGV when using ASAN on
                    code emitted from -emit-llvm
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: phil-llvm at teuwen.org
                CC: llvm-bugs at lists.llvm.org


Clang version: bug found when using clang 4, then confirmed with clang 5
(1:5.0~svn294894-1 from Debian)

When compiling in 2 steps (emitting IR code) and using ASAN, I get the
following error :

cat > hello.c << EOF
#include <stdio.h>

int main(void)
    printf("hello world\n");
    return 0;
clang-5.0 -fsanitize=address -S -emit-llvm hello.c -o hello.clang500.ll
clang-5.0 -fsanitize=address hello.clang500.ll -o hello.clang500
==26227==ERROR: AddressSanitizer: odr-violation (0x000000520dc0):
  [1] size=64 '.str' hello.clang500.ll
  [2] size=13 '<string literal>' hello.c:5:12
These globals were registered at these points:
    #0 0x432430  (/tmp/hello.clang500+0x432430)
    #1 0x50a106  (/tmp/hello.clang500+0x50a106)

    #0 0x432430  (/tmp/hello.clang500+0x432430)
    #1 0x50a0f0  (/tmp/hello.clang500+0x50a0f0)

==26227==HINT: if you don't care about these errors you may set
SUMMARY: AddressSanitizer: odr-violation: global '.str' at hello.clang500.ll

I will attach the emitted LL.

Now if I choose to ignore the odr-validation, I get a SEGV:

cat > hello2.c << EOF
#include <stdio.h>

int main(int argc, char *argv[])
    printf("Hello %s\n", argv[0]);
    return 0;
# Now ignoring previous error:
export ASAN_OPTIONS=detect_odr_violation=0
clang-5.0 -fsanitize=address -S -emit-llvm hello2.c -o hello2.clang500.ll
clang-5.0 -fsanitize=address hello2.clang500.ll -o hello2.clang500
==26433==ERROR: AddressSanitizer: SEGV on unknown address 0x0200865f1067 (pc
0x00000050a0ce bp 0x7ffd97e81910 sp 0x7ffd97e818e0 T0)
==26433==The signal is caused by a READ memory access.
    #0 0x50a0cd  (/tmp/hello2.clang500+0x50a0cd)
    #1 0x7ff1255cb2b0  (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    #2 0x41bef9  (/tmp/hello2.clang500+0x41bef9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/tmp/hello2.clang500+0x50a0cd) 

I will attach the emitted LL.

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/20170418/ff0fab51/attachment.html>

More information about the llvm-bugs mailing list