Andrew Haberlandt 99e8aa5ab4
[TSan] Fix TSan instrumenting pointers from non-default address spaces (#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
2026-01-06 09:11:28 -08:00
..