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 <mark@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
This commit is contained in:
Leonard Grey 2022-08-19 15:54:28 -04:00 committed by Mark Mentovai
parent 43ea32b6fe
commit a2d0cefe01

View File

@ -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);