Skip to content

Conversation

ndrewh
Copy link

@ndrewh ndrewh commented Oct 11, 2025

Cherry pick to 21.x: improvements to the sanitizer error handling and diagnostic messages on macOS

llvm#158378 - [sanitizer-common] Improve diagnostic when ASAN fails to allocate shadow
llvm#158665 - [sanitizer_common][tsan][Darwin] Improve message for unsupported vm config on Apple platforms
llvm#158670 - [sanitizer-common][Darwin] Improve mach_vm_region_recurse error handling
llvm#160171 - [compiler-rt] [TSan] [Darwin] Fix missing Report() arg in vm layout msg
llvm#161282 - [sanitizers][Darwin][NFC] Insert missing void* casts for printf %p

…dow (llvm#158378)

Sometimes we are unable to find a sufficiently large gap to allocate the
dynamic ASAN shadow.

If a gap is not found, we will now output a (consolidated) memory map to
show the user what regions were unavailable and how much memory we need.

rdar://159142896
(cherry picked from commit 1fea3c5)
…onfig on Apple platforms (llvm#158665)

An existing log message is triggered in InitializePlatformEarly if the
address space max is not as sufficient for TSAN.

Some Apple platforms expand the address space limit, but reserve much of
the space TSAN needs. Therefore, we now check that the kernel has not
mapped over the address space that we intend to use.

IsAddressInMappedRegion is added to sanitizer_common. This introduces a
new dependency on mach_vm_region_recurse during TSAN startup, so this
intentionally fails softly (to avoid breaking current users who may be
in a sandbox that doesn't allow this).

rdar://135265279
(cherry picked from commit 51a840e)
…ing (llvm#158670)

Some sanitizers use mach_vm_region_recurse on macOS to find a
sufficiently large gap to allocate shadow memory. Some sandboxes do not
allow this.

When we get KERN_DENIED, we suggest to the user that it may have been
blocked by the sandbox.

For error codes other than KERN_INVALID_ADDRESS and KERN_DENIED, we make
sure to log a message and not use the address.

rdar://160625998
(cherry picked from commit 8fb02fa)
…sg (llvm#160171)

This fixes a typo introduced in llvm#158665.

(cherry picked from commit e99c43c)
…lvm#161282)

Add some missing void* casts where we were passing an int for %p on some
platforms.

rdar://161174839
(cherry picked from commit 5960f5c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants