diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp --- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp @@ -608,10 +608,10 @@ static MacosVersion GetMacosAlignedVersionInternal() { u16 kernel_major = GetDarwinKernelVersion().major; - const u16 version_offset = 4; - CHECK_GE(kernel_major, version_offset); - u16 macos_major = kernel_major - version_offset; - return MacosVersion(10, macos_major); + CHECK_GE(kernel_major, 4); + if (kernel_major >= 20) + return MacosVersion(11, kernel_major - 20); + return MacosVersion(10, kernel_major - 4); } static_assert(sizeof(MacosVersion) == sizeof(atomic_uint32_t::Type), diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_mac_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_mac_test.cpp --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_mac_test.cpp +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_mac_test.cpp @@ -24,8 +24,12 @@ TEST(SanitizerMac, GetMacosAlignedVersion) { MacosVersion vers = GetMacosAlignedVersion(); - EXPECT_EQ(vers.major, 10); - EXPECT_EQ(vers.minor, GetDarwinKernelVersion().major - 4); + u16 kernel_major = GetDarwinKernelVersion().major; + bool macos_11 = kernel_major >= 20; + u16 expected_major = macos_11 ? 11 : 10; + u16 expected_minor = kernel_major - (macos_11 ? 20 : 4); + EXPECT_EQ(vers.major, expected_major); + EXPECT_EQ(vers.minor, expected_minor); } void ParseVersion(const char *vers, u16 *major, u16 *minor);