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