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 @@ -644,6 +644,10 @@ auto format = TARGET_OS_OSX ? "10.%d" : "%d.0"; len = internal_snprintf(vers, len, format, os_major); + } else if (internal_strlen(vers) < 3) { + // Fallback for cases when sanitizer initialization runs before sysctl is + // setup. Assume we run on a "very new" version of the OS. + len = internal_snprintf(vers, sizeof(VersStr), "99.0"); } } CHECK_LT(len, sizeof(VersStr));