<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - -fsanitize=function doesn't work with dlopen"
href="https://llvm.org/bugs/show_bug.cgi?id=26989">26989</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-fsanitize=function doesn't work with dlopen
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>peter@pcc.me.uk
</td>
</tr>
<tr>
<th>Reporter</th>
<td>vonosmas@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Reproducer:
$ cat dlopen-test.cc
#include <dlfcn.h>
int main() {
void *dl_handle = dlopen("dlopen_test.so", RTLD_NOW | RTLD_LOCAL);
typedef int (*IncFn)(int);
IncFn inc = reinterpret_cast<IncFn>(dlsym(dl_handle, "my_inc"));
return (1 != inc(0));
}
$ cat dlopen_so.cc
extern "C" int my_inc(int a) {
return a + 1;
}
$ ./bin/clang++ -fsanitize=function dlopen_so.cc -shared -o dlopen_test.so -g
$ ./bin/clang++ -fsanitize=function dlopen-test.cc -g
$ ./a.out
dlopen-test.cc:7:16: runtime error: call to function my_inc through pointer to
incorrect function type 'int (*)(int)'
dlopen_so.cc:1: note: my_inc defined here
We have two different versions of RTTI for int (*)(int) (_ZTIFiiE) - one in the
main executable, and one in the shared library. Before the indirect call
to "my_inc" through function pointer, we verify that the prologue of "my_inc"
contains a pointer to _ZTIFiiE in the main executable, but my_inc prologue
instead contains pointer to _ZTIFiiE in shared library, which is not merged.
This leads to a false positive.</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>