From a2d0cefe018b9c33ce9ac4305e4aae610d63ed68 Mon Sep 17 00:00:00 2001 From: Leonard Grey Date: Fri, 19 Aug 2022 15:54:28 -0400 Subject: [PATCH] Mac: account for PTHREAD_T_OFFSET in arm64 tests Bug: chromium:1319307 Change-Id: I3d462b7f143b63eb3173eb7245a6c0df4f75e778 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3842365 Reviewed-by: Mark Mentovai Commit-Queue: Leonard Grey --- snapshot/mac/process_reader_mac_test.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/snapshot/mac/process_reader_mac_test.cc b/snapshot/mac/process_reader_mac_test.cc index 7921311a..93527cfb 100644 --- a/snapshot/mac/process_reader_mac_test.cc +++ b/snapshot/mac/process_reader_mac_test.cc @@ -359,8 +359,15 @@ void ExpectSeveralThreads(ThreadMap* thread_map, mach_vm_address_t expected_stack_region_end = iterator->second.stack_base; if (thread_index > 0) { // Non-main threads use the stack region to store thread data. See - // _pthread_allocate. + // macOS 12 libpthread-486.100.11 src/pthread.c _pthread_allocate(). +#if defined(ARCH_CPU_ARM64) + // arm64 has an additional offset for alignment. See macOS 12 + // libpthread-486.100.11 src/pthread.c _pthread_allocate() and + // PTHREAD_T_OFFSET (defined in src/types_internal.h). + expected_stack_region_end += sizeof(_opaque_pthread_t) + 0x3000; +#else expected_stack_region_end += sizeof(_opaque_pthread_t); +#endif } EXPECT_LT(iterator->second.stack_base - iterator->second.stack_size, thread.stack_region_address);