Skip to content

Conversation

@ndrewh
Copy link

@ndrewh ndrewh commented Jan 6, 2026

Cherry-pick llvm#174518

llvm#174518)

Casting a pointer to a different address space is a nice trick to
prevent an access from being instrumented by sanitizers such as ASan.
However, this trick is currently broken, as the test demonstrates.

A minimal C PoC of the issue is:

```
void access(void *p) {
  auto tmp = (unsigned long __attribute__((address_space(1))) volatile *)p;
  *tmp = 0;
}
```

Under fsanitize=address, the access does not get instrumented, but under
fsanitize=thread, it does.

(Note: Before this patch, this test will actually hit a CallInst
assertion if you have them turned on, because the TSan runtime functions
are defined to take pointer arguments, and non-default address space
pointers are not compatible).

rdar://166743781
(cherry picked from commit 99e8aa5)
@ndrewh ndrewh requested a review from DanBlackwell January 6, 2026 17:29
@ndrewh ndrewh requested a review from a team as a code owner January 6, 2026 17:29
@ndrewh
Copy link
Author

ndrewh commented Jan 6, 2026

@swift-ci please test

@DanBlackwell
Copy link

@swift-ci please test macOS

@DanBlackwell
Copy link

@swift-ci please test macOS

3 similar comments
@ndrewh
Copy link
Author

ndrewh commented Jan 7, 2026

@swift-ci please test macOS

@DanBlackwell
Copy link

@swift-ci please test macOS

@ndrewh
Copy link
Author

ndrewh commented Jan 8, 2026

@swift-ci please test macOS

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.

2 participants