1// RUN: %clangxx_msan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
2
3#include <assert.h>
4#include <dlfcn.h>
5#include <stdlib.h>
6
7static int my_global;
8
9int main(void) {
10 int *uninit = (int*)malloc(size: sizeof(int));
11 my_global = *uninit;
12 void *p = dlopen(file: 0, RTLD_NOW);
13 assert(p && "failed to get handle to executable");
14 return my_global;
15 // CHECK: MemorySanitizer: use-of-uninitialized-value
16 // CHECK: #0 {{.*}} in main{{.*}}dlopen_executable.cpp:[[@LINE-2]]
17}
18

source code of compiler-rt/test/msan/dlopen_executable.cpp