aboutsummaryrefslogtreecommitdiff
path: root/src/client/windows
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2017-03-17 17:55:46 +0000
committerMike Frysinger <vapier@chromium.org>2017-03-17 19:15:06 +0000
commit0c3b559653d011bd9f171c945de1570c66fb15fc (patch)
treeff48ed211fa8059796e8aa4df66c42d202437317 /src/client/windows
parentFix issues with Windows dump_syms_unittest (diff)
downloadbreakpad-0c3b559653d011bd9f171c945de1570c66fb15fc.tar.xz
Fix sporadic failure of InstructionPointerMemory test on Windows
If another memory region of interest (e.g. a thread stack) randomly happens to lie immediately before the page allocated by this test, the memory regions can be coalesced in the minidump generated. Relax this test so it correctly handles the case where the expected 256 bytes around the IP aren't at the start of the minidump memory region. Alternatively, that could be avoided by reserving the page before the page used for this test, in which case this test is degenerate with InstructionPointerMemoryMinBound and can be removed. BUG= Change-Id: Ib1bfb242b2c0acaa090df68334a02ac434ad880c Reviewed-on: https://chromium-review.googlesource.com/456702 Reviewed-by: Mike Frysinger <vapier@chromium.org>
Diffstat (limited to 'src/client/windows')
-rw-r--r--src/client/windows/unittests/exception_handler_death_test.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/client/windows/unittests/exception_handler_death_test.cc b/src/client/windows/unittests/exception_handler_death_test.cc
index 079ca3d6..30600d41 100644
--- a/src/client/windows/unittests/exception_handler_death_test.cc
+++ b/src/client/windows/unittests/exception_handler_death_test.cc
@@ -357,8 +357,8 @@ TEST_F(ExceptionHandlerDeathTest, InstructionPointerMemory) {
// Read the minidump. Locate the exception record and the
// memory list, and then ensure that there is a memory region
- // in the memory list that covers the instruction pointer from
- // the exception record.
+ // in the memory list that covers at least 128 bytes on either
+ // side of the instruction pointer from the exception record.
{
Minidump minidump(minidump_filename);
ASSERT_TRUE(minidump.Read());
@@ -379,18 +379,23 @@ TEST_F(ExceptionHandlerDeathTest, InstructionPointerMemory) {
memory_list->GetMemoryRegionForAddress(instruction_pointer);
ASSERT_TRUE(region);
- EXPECT_EQ(kMemorySize, region->GetSize());
+ EXPECT_LE(kMemorySize, region->GetSize());
const uint8_t* bytes = region->GetMemory();
ASSERT_TRUE(bytes);
+ uint64_t ip_offset = instruction_pointer - region->GetBase();
+ EXPECT_GE(region->GetSize() - kOffset, ip_offset);
+ EXPECT_LE(kOffset, ip_offset);
+
uint8_t prefix_bytes[kOffset];
uint8_t suffix_bytes[kMemorySize - kOffset - sizeof(instructions)];
memset(prefix_bytes, 0, sizeof(prefix_bytes));
memset(suffix_bytes, 0, sizeof(suffix_bytes));
- EXPECT_EQ(0, memcmp(bytes, prefix_bytes, sizeof(prefix_bytes)));
- EXPECT_EQ(0, memcmp(bytes + kOffset, instructions, sizeof(instructions)));
- EXPECT_EQ(0, memcmp(bytes + kOffset + sizeof(instructions),
- suffix_bytes, sizeof(suffix_bytes)));
+ EXPECT_EQ(0, memcmp(bytes + ip_offset - kOffset, prefix_bytes,
+ sizeof(prefix_bytes)));
+ EXPECT_EQ(0, memcmp(bytes + ip_offset, instructions, sizeof(instructions)));
+ EXPECT_EQ(0, memcmp(bytes + ip_offset + sizeof(instructions), suffix_bytes,
+ sizeof(suffix_bytes)));
}
DeleteFileW(minidump_filename_wide.c_str());