[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-23 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL337694: Add support for parsing Breakpad minidump files that 
can have extra padding in… (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49579?vs=156545=156779#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49579

Files:
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
  lldb/trunk/unittests/Process/minidump/CMakeLists.txt
  lldb/trunk/unittests/Process/minidump/Inputs/memory-list-not-padded.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/memory-list-padded.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/module-list-not-padded.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/module-list-padded.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/thread-list-not-padded.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/thread-list-padded.dmp
  lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -84,6 +84,76 @@
   EXPECT_EQ(1232UL, context.size());
 }
 
+TEST_F(MinidumpParserTest, GetThreadListNotPadded) {
+  // Verify that we can load a thread list that doesn't have 4 bytes of padding
+  // after the thread count.
+  SetUpData("thread-list-not-padded.dmp");
+  llvm::ArrayRef thread_list;
+  
+  thread_list = parser->GetThreads();
+  ASSERT_EQ(2UL, thread_list.size());
+  EXPECT_EQ(0x11223344UL, thread_list[0].thread_id);
+  EXPECT_EQ(0x55667788UL, thread_list[1].thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetThreadListPadded) {
+  // Verify that we can load a thread list that has 4 bytes of padding
+  // after the thread count as found in breakpad minidump files.
+  SetUpData("thread-list-padded.dmp");
+  auto thread_list = parser->GetThreads();
+  ASSERT_EQ(2UL, thread_list.size());
+  EXPECT_EQ(0x11223344UL, thread_list[0].thread_id);
+  EXPECT_EQ(0x55667788UL, thread_list[1].thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetModuleListNotPadded) {
+  // Verify that we can load a module list that doesn't have 4 bytes of padding
+  // after the module count.
+  SetUpData("module-list-not-padded.dmp");
+  auto module_list = parser->GetModuleList();
+  ASSERT_EQ(2UL, module_list.size());
+  EXPECT_EQ(0x1000UL, module_list[0].base_of_image);
+  EXPECT_EQ(0x2000UL, module_list[0].size_of_image);
+  EXPECT_EQ(0x5000UL, module_list[1].base_of_image);
+  EXPECT_EQ(0x3000UL, module_list[1].size_of_image);
+}
+
+TEST_F(MinidumpParserTest, GetModuleListPadded) {
+  // Verify that we can load a module list that has 4 bytes of padding
+  // after the module count as found in breakpad minidump files.
+  SetUpData("module-list-padded.dmp");
+  auto module_list = parser->GetModuleList();
+  ASSERT_EQ(2UL, module_list.size());
+  EXPECT_EQ(0x1000UL, module_list[0].base_of_image);
+  EXPECT_EQ(0x2000UL, module_list[0].size_of_image);
+  EXPECT_EQ(0x5000UL, module_list[1].base_of_image);
+  EXPECT_EQ(0x3000UL, module_list[1].size_of_image);
+}
+
+TEST_F(MinidumpParserTest, GetMemoryListNotPadded) {
+  // Verify that we can load a memory list that doesn't have 4 bytes of padding
+  // after the memory range count.
+  SetUpData("memory-list-not-padded.dmp");
+  auto mem = parser->FindMemoryRange(0x8000);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8000, mem->start);
+  mem = parser->FindMemoryRange(0x8010);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8010, mem->start);
+}
+
+TEST_F(MinidumpParserTest, GetMemoryListPadded) {
+  // Verify that we can load a memory list that has 4 bytes of padding
+  // after the memory range count as found in breakpad minidump files.
+  SetUpData("memory-list-padded.dmp");
+  auto mem = parser->FindMemoryRange(0x8000);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8000, mem->start);
+  mem = parser->FindMemoryRange(0x8010);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8010, mem->start);
+}
+
 TEST_F(MinidumpParserTest, TruncatedMinidumps) {
   InvalidMinidump("linux-x86_64.dmp", 32);
   InvalidMinidump("linux-x86_64.dmp", 100);
Index: lldb/trunk/unittests/Process/minidump/CMakeLists.txt
===
--- lldb/trunk/unittests/Process/minidump/CMakeLists.txt
+++ lldb/trunk/unittests/Process/minidump/CMakeLists.txt
@@ -19,6 +19,12 @@
fizzbuzz_no_heap.dmp
fizzbuzz_wow64.dmp
bad_duplicate_streams.dmp
-   bad_overlapping_streams.dmp)
+   bad_overlapping_streams.dmp
+   thread-list-padded.dmp
+   thread-list-not-padded.dmp
+   module-list-padded.dmp
+   module-list-not-padded.dmp
+   memory-list-padded.dmp
+   memory-list-not-padded.dmp)
 
 add_unittest_inputs(LLDBMinidumpTests "${test_inputs}")

[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-23 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

The extra padding is unfortunate, but I guess we have to live with it now.

Looks good. Thanks.


https://reviews.llvm.org/D49579



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-20 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Thanks for the info. Pavel? This good to go? I have another patch that adds the 
ARM and ARM64 support that will quickly follow.


https://reviews.llvm.org/D49579



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-20 Thread Mark Mentovai via Phabricator via lldb-commits
markmentovai added a comment.

I know, that was a mistake.

(Unfortunately, I reviewed it. 11 years ago. And now I feel responsible for all 
of those malformed minidumps floating around out there.)

If you do need to do this, it seems fine to me, since it’s basically the same 
exact workaround. If we fix the Breakpad writer up to write minidumps correctly 
(as Crashpad and dbghelp do), the workaround should go dormant, so it’s no 
problem from my perspective.


https://reviews.llvm.org/D49579



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-20 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

BTW: The padding fix was inspired from the breakpad sources as they do this 
exact same thing.


https://reviews.llvm.org/D49579



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-20 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 156545.
clayborg added a comment.

Remove xcode project changes.


https://reviews.llvm.org/D49579

Files:
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/memory-list-not-padded.dmp
  unittests/Process/minidump/Inputs/memory-list-padded.dmp
  unittests/Process/minidump/Inputs/module-list-not-padded.dmp
  unittests/Process/minidump/Inputs/module-list-padded.dmp
  unittests/Process/minidump/Inputs/thread-list-not-padded.dmp
  unittests/Process/minidump/Inputs/thread-list-padded.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -84,6 +84,76 @@
   EXPECT_EQ(1232UL, context.size());
 }
 
+TEST_F(MinidumpParserTest, GetThreadListNotPadded) {
+  // Verify that we can load a thread list that doesn't have 4 bytes of padding
+  // after the thread count.
+  SetUpData("thread-list-not-padded.dmp");
+  llvm::ArrayRef thread_list;
+  
+  thread_list = parser->GetThreads();
+  ASSERT_EQ(2UL, thread_list.size());
+  EXPECT_EQ(0x11223344UL, thread_list[0].thread_id);
+  EXPECT_EQ(0x55667788UL, thread_list[1].thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetThreadListPadded) {
+  // Verify that we can load a thread list that has 4 bytes of padding
+  // after the thread count as found in breakpad minidump files.
+  SetUpData("thread-list-padded.dmp");
+  auto thread_list = parser->GetThreads();
+  ASSERT_EQ(2UL, thread_list.size());
+  EXPECT_EQ(0x11223344UL, thread_list[0].thread_id);
+  EXPECT_EQ(0x55667788UL, thread_list[1].thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetModuleListNotPadded) {
+  // Verify that we can load a module list that doesn't have 4 bytes of padding
+  // after the module count.
+  SetUpData("module-list-not-padded.dmp");
+  auto module_list = parser->GetModuleList();
+  ASSERT_EQ(2UL, module_list.size());
+  EXPECT_EQ(0x1000UL, module_list[0].base_of_image);
+  EXPECT_EQ(0x2000UL, module_list[0].size_of_image);
+  EXPECT_EQ(0x5000UL, module_list[1].base_of_image);
+  EXPECT_EQ(0x3000UL, module_list[1].size_of_image);
+}
+
+TEST_F(MinidumpParserTest, GetModuleListPadded) {
+  // Verify that we can load a module list that has 4 bytes of padding
+  // after the module count as found in breakpad minidump files.
+  SetUpData("module-list-padded.dmp");
+  auto module_list = parser->GetModuleList();
+  ASSERT_EQ(2UL, module_list.size());
+  EXPECT_EQ(0x1000UL, module_list[0].base_of_image);
+  EXPECT_EQ(0x2000UL, module_list[0].size_of_image);
+  EXPECT_EQ(0x5000UL, module_list[1].base_of_image);
+  EXPECT_EQ(0x3000UL, module_list[1].size_of_image);
+}
+
+TEST_F(MinidumpParserTest, GetMemoryListNotPadded) {
+  // Verify that we can load a memory list that doesn't have 4 bytes of padding
+  // after the memory range count.
+  SetUpData("memory-list-not-padded.dmp");
+  auto mem = parser->FindMemoryRange(0x8000);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8000, mem->start);
+  mem = parser->FindMemoryRange(0x8010);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8010, mem->start);
+}
+
+TEST_F(MinidumpParserTest, GetMemoryListPadded) {
+  // Verify that we can load a memory list that has 4 bytes of padding
+  // after the memory range count as found in breakpad minidump files.
+  SetUpData("memory-list-padded.dmp");
+  auto mem = parser->FindMemoryRange(0x8000);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8000, mem->start);
+  mem = parser->FindMemoryRange(0x8010);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8010, mem->start);
+}
+
 TEST_F(MinidumpParserTest, TruncatedMinidumps) {
   InvalidMinidump("linux-x86_64.dmp", 32);
   InvalidMinidump("linux-x86_64.dmp", 100);
Index: unittests/Process/minidump/CMakeLists.txt
===
--- unittests/Process/minidump/CMakeLists.txt
+++ unittests/Process/minidump/CMakeLists.txt
@@ -19,6 +19,12 @@
fizzbuzz_no_heap.dmp
fizzbuzz_wow64.dmp
bad_duplicate_streams.dmp
-   bad_overlapping_streams.dmp)
+   bad_overlapping_streams.dmp
+   thread-list-padded.dmp
+   thread-list-not-padded.dmp
+   module-list-padded.dmp
+   module-list-not-padded.dmp
+   memory-list-padded.dmp
+   memory-list-not-padded.dmp)
 
 add_unittest_inputs(LLDBMinidumpTests "${test_inputs}")
Index: source/Plugins/Process/minidump/MinidumpTypes.cpp
===
--- source/Plugins/Process/minidump/MinidumpTypes.cpp
+++ source/Plugins/Process/minidump/MinidumpTypes.cpp
@@ -81,11 +81,17 @@
 
 llvm::ArrayRef
 MinidumpThread::ParseThreadList(llvm::ArrayRef ) {
+  const auto orig_size = data.size();
   const llvm::support::ulittle32_t *thread_count;
   Status error 

[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-20 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 156544.
clayborg added a comment.
Herald added subscribers: mgorny, srhines.

Improve comments to indicate why padding might be there, fix a test case to use 
the right file, and add all new .dmp files to the CMakeLists.txt


https://reviews.llvm.org/D49579

Files:
  lldb.xcodeproj/project.pbxproj
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  unittests/Process/minidump/CMakeLists.txt
  unittests/Process/minidump/Inputs/memory-list-not-padded.dmp
  unittests/Process/minidump/Inputs/memory-list-padded.dmp
  unittests/Process/minidump/Inputs/module-list-not-padded.dmp
  unittests/Process/minidump/Inputs/module-list-padded.dmp
  unittests/Process/minidump/Inputs/thread-list-not-padded.dmp
  unittests/Process/minidump/Inputs/thread-list-padded.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-20 Thread Mark Mentovai via Phabricator via lldb-commits
markmentovai added a comment.

This has got to be padding.

Breakpad’s structure definitions don’t nail down alignment as they probably 
should. A 32-bit system writing an MDRawMemoryList will write what’s intended, 
but a 64-bit one will need to insert four bytes of padding after 
number_of_memory_ranges to make sure that the array elements that follow are 
aligned.

Oops.

Microsoft’s own structure definitions don’t have this problem, and neither do 
Crashpad’s (example 
).

I think it’d be preferable to fix Breakpad to not write bogus minidumps. It’s 
absolutely wrong, and other code will have interoperability problems too.

Greg, if we fix Breakpad, will you still need this for old dumps, or are you OK 
wiping the slate clean?


https://reviews.llvm.org/D49579



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-20 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

The "sometimes" depends on how compilers pad the structures that define the 
lists. Since the structs look like:

  struct MemoryList {
uint32_t count;
MemoryDescriptor descriptors[];
  };

The compiler might end up padding and extra 4 bytes depending on what is in the 
struct that follows the count. I can clarify this in my comments.


https://reviews.llvm.org/D49579



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a subscriber: lemo.
labath added a comment.

@markmentovai, @lemo, do you know under which circumstances do these extra 4 
bytes get emitted? Is there any chance we could document this better than just 
saying "sometimes"?




Comment at: unittests/Process/minidump/MinidumpParserTest.cpp:90
+  // after the thread count.
+  SetUpData("thread-list-padded.dmp");
+  llvm::ArrayRef thread_list;

You'll also need to add these files to 
`unittests/Process/minidump/CMakeLists.txt`. Otherwise the tests won't work 
from cmake.



Comment at: unittests/Process/minidump/MinidumpParserTest.cpp:151-152
+  auto mem = parser->FindMemoryRange(0x8000);
+  EXPECT_TRUE(mem.hasValue());
+  if (mem.hasValue())
+EXPECT_EQ((lldb::addr_t)0x8000, mem->start);

You can avoid the if statement by changing the previous check to `ASSERT_TRUE`. 
ASSERT_*** macros automatically terminate the test if they fail so you won't 
get a crash there.


https://reviews.llvm.org/D49579



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-19 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: labath, zturner.

Breakpad files sometimes extra 4 bytes of padding after the 32 bit count for 
memory, module and thread lists. I also created bare minimum minidump files 
that contain both padded and not padded files that test each functionality 
works correctly.


https://reviews.llvm.org/D49579

Files:
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  unittests/Process/minidump/Inputs/memory-list-not-padded.dmp
  unittests/Process/minidump/Inputs/memory-list-padded.dmp
  unittests/Process/minidump/Inputs/module-list-not-padded.dmp
  unittests/Process/minidump/Inputs/module-list-padded.dmp
  unittests/Process/minidump/Inputs/thread-list-not-padded.dmp
  unittests/Process/minidump/Inputs/thread-list-padded.dmp
  unittests/Process/minidump/MinidumpParserTest.cpp

Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -84,6 +84,79 @@
   EXPECT_EQ(1232UL, context.size());
 }
 
+TEST_F(MinidumpParserTest, GetThreadListNotPadded) {
+  // Verify that we can load a thread list that doesn't have 4 bytes of padding
+  // after the thread count.
+  SetUpData("thread-list-padded.dmp");
+  llvm::ArrayRef thread_list;
+  
+  thread_list = parser->GetThreads();
+  ASSERT_EQ(2UL, thread_list.size());
+  EXPECT_EQ(0x11223344UL, thread_list[0].thread_id);
+  EXPECT_EQ(0x55667788UL, thread_list[1].thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetThreadListPadded) {
+  // Verify that we can load a thread list that has 4 bytes of padding
+  // after the thread count as found in breakpad minidump files.
+  SetUpData("thread-list-padded.dmp");
+  auto thread_list = parser->GetThreads();
+  ASSERT_EQ(2UL, thread_list.size());
+  EXPECT_EQ(0x11223344UL, thread_list[0].thread_id);
+  EXPECT_EQ(0x55667788UL, thread_list[1].thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetModuleListNotPadded) {
+  // Verify that we can load a module list that doesn't have 4 bytes of padding
+  // after the module count.
+  SetUpData("module-list-not-padded.dmp");
+  auto module_list = parser->GetModuleList();
+  ASSERT_EQ(2UL, module_list.size());
+  EXPECT_EQ(0x1000UL, module_list[0].base_of_image);
+  EXPECT_EQ(0x2000UL, module_list[0].size_of_image);
+  EXPECT_EQ(0x5000UL, module_list[1].base_of_image);
+  EXPECT_EQ(0x3000UL, module_list[1].size_of_image);
+}
+
+TEST_F(MinidumpParserTest, GetModuleListPadded) {
+  // Verify that we can load a module list that has 4 bytes of padding
+  // after the module count as found in breakpad minidump files.
+  SetUpData("module-list-padded.dmp");
+  auto module_list = parser->GetModuleList();
+  ASSERT_EQ(2UL, module_list.size());
+  EXPECT_EQ(0x1000UL, module_list[0].base_of_image);
+  EXPECT_EQ(0x2000UL, module_list[0].size_of_image);
+  EXPECT_EQ(0x5000UL, module_list[1].base_of_image);
+  EXPECT_EQ(0x3000UL, module_list[1].size_of_image);
+}
+
+TEST_F(MinidumpParserTest, GetMemoryListNotPadded) {
+  // Verify that we can load a memory list that doesn't have 4 bytes of padding
+  // after the memory range count.
+  SetUpData("memory-list-not-padded.dmp");
+  
+  if (auto mem = parser->FindMemoryRange(0x8000)) {
+EXPECT_EQ((lldb::addr_t)0x8000, mem->start);
+  }
+  if (auto mem = parser->FindMemoryRange(0x8010)) {
+EXPECT_EQ((lldb::addr_t)0x8010, mem->start);
+  }
+}
+
+TEST_F(MinidumpParserTest, GetMemoryListPadded) {
+  // Verify that we can load a memory list that has 4 bytes of padding
+  // after the memory range count as found in breakpad minidump files.
+  SetUpData("memory-list-padded.dmp");
+  auto mem = parser->FindMemoryRange(0x8000);
+  EXPECT_TRUE(mem.hasValue());
+  if (mem.hasValue())
+EXPECT_EQ((lldb::addr_t)0x8000, mem->start);
+  mem = parser->FindMemoryRange(0x8010);
+  EXPECT_TRUE(mem.hasValue());
+  if (mem.hasValue())
+EXPECT_EQ((lldb::addr_t)0x8010, mem->start);
+}
+
 TEST_F(MinidumpParserTest, TruncatedMinidumps) {
   InvalidMinidump("linux-x86_64.dmp", 32);
   InvalidMinidump("linux-x86_64.dmp", 100);
Index: source/Plugins/Process/minidump/MinidumpTypes.cpp
===
--- source/Plugins/Process/minidump/MinidumpTypes.cpp
+++ source/Plugins/Process/minidump/MinidumpTypes.cpp
@@ -81,11 +81,17 @@
 
 llvm::ArrayRef
 MinidumpThread::ParseThreadList(llvm::ArrayRef ) {
+  const auto orig_size = data.size();
+
   const llvm::support::ulittle32_t *thread_count;
   Status error = consumeObject(data, thread_count);
   if (error.Fail() || *thread_count * sizeof(MinidumpThread) > data.size())
 return {};
 
+  // Sometimes there is padding after the count
+  if (4 + *thread_count * sizeof(MinidumpThread) < orig_size)
+data = data.drop_front(4);
+
   return llvm::ArrayRef(
   reinterpret_cast(data.data()), *thread_count);
 }
@@ -158,8 +164,15 @@
 llvm::ArrayRef