1 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
2 
3 // REQUIRES: x86_64-target-arch
4 
5 #include <pthread.h>
6 #include <signal.h>
7 #include <ucontext.h>
8 
9 void handler(int sig, siginfo_t *info, void *uctx) {
10   volatile int uninit;
11   auto *mctx = &static_cast<ucontext_t *>(uctx)->uc_mcontext;
12   auto *fpregs = mctx->fpregs;
13   if (fpregs && fpregs->__glibc_reserved1[12] == FP_XSTATE_MAGIC1)
14     reinterpret_cast<_xstate *>(mctx->fpregs)->ymmh.ymmh_space[0] = uninit;
15   else
16     mctx->gregs[REG_RAX] = uninit;
17 }
18 
19 int main(int argc, char **argv) {
20   struct sigaction act = {};
21   act.sa_sigaction = handler;
22   act.sa_flags = SA_SIGINFO;
23   sigfillset(&act.sa_mask);
24   sigaction(SIGPROF, &act, 0);
25   pthread_kill(pthread_self(), SIGPROF);
26   return 0;
27 }
28 
29 // CHECK: WARNING: MemorySanitizer:
30