mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 10:01:42 +00:00
4029426b17
Summary: dlopen(NULL, ...) is intended to give you back a handle to the executable for use with dlsym. Casting it to link_map and using it with ForEachMappedRegion results in a crash. We also shouldn't unpoison the globals of a DSO that is already in memory. This ensures that we don't do it for the executable, but in general, MSan may have false negatives if the DSO is already loaded. Reviewers: eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14795 llvm-svn: 253530
18 lines
469 B
C++
18 lines
469 B
C++
// RUN: %clangxx_msan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
|
|
|
|
#include <assert.h>
|
|
#include <dlfcn.h>
|
|
#include <stdlib.h>
|
|
|
|
static int my_global;
|
|
|
|
int main(void) {
|
|
int *uninit = (int*)malloc(sizeof(int));
|
|
my_global = *uninit;
|
|
void *p = dlopen(0, RTLD_NOW);
|
|
assert(p && "failed to get handle to executable");
|
|
return my_global;
|
|
// CHECK: MemorySanitizer: use-of-uninitialized-value
|
|
// CHECK: #0 {{.*}} in main{{.*}}dlopen_executable.cc:[[@LINE-2]]
|
|
}
|