1 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
3 // musl does not define FP_XSTATE_MAGIC1.
4 // REQUIRES: x86_64-target-arch && glibc-2.27
11 void handler(int sig
, siginfo_t
*info
, void *uctx
) {
13 auto *mctx
= &static_cast<ucontext_t
*>(uctx
)->uc_mcontext
;
14 auto *fpregs
= mctx
->fpregs
;
15 // The member names differ across header versions, but the actual layout
16 // is always the same. So avoid using members, just use arithmetic.
17 const uint32_t *after_xmm
=
18 reinterpret_cast<const uint32_t *>(fpregs
+ 1) - 24;
19 if (after_xmm
[12] == FP_XSTATE_MAGIC1
)
20 reinterpret_cast<_xstate
*>(mctx
->fpregs
)->ymmh
.ymmh_space
[0] = uninit
;
22 mctx
->gregs
[REG_RAX
] = uninit
;
25 int main(int argc
, char **argv
) {
26 struct sigaction act
= {};
27 act
.sa_sigaction
= handler
;
28 act
.sa_flags
= SA_SIGINFO
;
29 sigfillset(&act
.sa_mask
);
30 sigaction(SIGPROF
, &act
, 0);
31 pthread_kill(pthread_self(), SIGPROF
);
35 // CHECK: WARNING: MemorySanitizer: