<html>
<head>
<base href="http://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - odr-violation and, if ignored, SEGV when using ASAN on code emitted from -emit-llvm"
href="http://bugs.llvm.org/show_bug.cgi?id=32700">32700</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>odr-violation and, if ignored, SEGV when using ASAN on code emitted from -emit-llvm
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>4.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>phil-llvm@teuwen.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Hello
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;
}
EOF
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
./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:
[1]:
#0 0x432430 (/tmp/hello.clang500+0x432430)
#1 0x50a106 (/tmp/hello.clang500+0x50a106)
[2]:
#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
ASAN_OPTIONS=detect_odr_violation=0
SUMMARY: AddressSanitizer: odr-violation: global '.str' at hello.clang500.ll
==26227==ABORTING
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;
}
EOF
# 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
./hello2.clang500
ASAN:DEADLYSIGNAL
=================================================================
==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)
==26433==ABORTING
I will attach the emitted LL.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>