linux, x86/x64: set fpregs to nullptr in CaptureContext()

uc_mcontext.fpregs is a pointer to the floating point context, but
CaptureContext() doesn't yet capture floating point context.

This error manages to slip by unit tests when run all together, but
fails when CrashpadClient.SimulateCrash is run by itself.

Bug: crashpad:30
Change-Id: I7adc30648642912d66a7ba8cf9973c9bc0fbd8bc
Reviewed-on: https://chromium-review.googlesource.com/1011504
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Joshua Peraza 2018-04-12 16:45:35 -07:00 committed by Commit Bot
parent 091308be6a
commit dd4ba4c8a1
3 changed files with 10 additions and 11 deletions

View File

@ -210,19 +210,12 @@ bool CrashpadClient::StartHandlerForClient(
void CrashpadClient::DumpWithoutCrash(NativeCPUContext* context) {
DCHECK(g_crash_handler);
#if defined(ARCH_CPU_X86)
memset(&context->__fpregs_mem, 0, sizeof(context->__fpregs_mem));
context->__fpregs_mem.status = 0xffff0000;
#elif defined(ARCH_CPU_X86_64)
memset(&context->__fpregs_mem, 0, sizeof(context->__fpregs_mem));
#elif defined(ARCH_CPU_ARMEL)
#if defined(ARCH_CPU_ARMEL)
memset(context->uc_regspace, 0, sizeof(context->uc_regspace));
#elif defined(ARCH_CPU_ARM64)
memset(context->uc_mcontext.__reserved,
0,
sizeof(context->uc_mcontext.__reserved));
#else
#error Port.
#endif
siginfo_t siginfo;

View File

@ -128,6 +128,8 @@ CAPTURECONTEXT_SYMBOL2:
movl %ecx, 0x5c(%eax) // context->uc_mcontext.xss
// TODO(jperaza): save floating-point registers.
xorl %ecx, %ecx
movl %ecx, 0x60(%eax) // context->uc_mcontext.fpregs
// Clean up by restoring clobbered registers, even those considered volatile
// by the ABI, so that the captured context represents the state at this
@ -224,14 +226,15 @@ CAPTURECONTEXT_SYMBOL2:
movq %r8, 0xd0(%rdi) // context->uc_mcontext.oldmask
movq %r8, 0xd8(%rdi) // context->uc_mcontext.cr2
// TODO(jperaza): save floating-point registers.
movq %r8, 0xe0(%rdi) // context->uc_mcontext.fpregs
// Clean up by restoring clobbered registers, even those considered volatile
// by the ABI, so that the captured context represents the state at this
// functions exit.
movq 0x90(%rdi), %rax
movq 0x28(%rdi), %r8
// TODO(jperaza): save floating-point registers.
popfq
popq %rbp

View File

@ -23,10 +23,13 @@ namespace test {
void SanityCheckContext(const NativeCPUContext& context) {
#if defined(ARCH_CPU_X86)
// Nothing to do here yet.
// TODO(jperaza): fpregs is nullptr until CaptureContext() supports capturing
// floating point context.
EXPECT_EQ(context.uc_mcontext.fpregs, nullptr);
#elif defined(ARCH_CPU_X86_64)
EXPECT_EQ(context.uc_mcontext.gregs[REG_RDI],
FromPointerCast<intptr_t>(&context));
EXPECT_EQ(context.uc_mcontext.fpregs, nullptr);
#elif defined(ARCH_CPU_ARMEL)
EXPECT_EQ(context.uc_mcontext.arm_r0, FromPointerCast<uintptr_t>(&context));
#elif defined(ARCH_CPU_ARM64)