[TSan][Darwin] Make malloc_size interceptor more robust
authorJulian Lettner <julian.lettner@apple.com>
Fri, 17 Dec 2021 03:33:12 +0000 (19:33 -0800)
committerJulian Lettner <julian.lettner@apple.com>
Fri, 17 Dec 2021 23:38:08 +0000 (15:38 -0800)
commit4399f3b6b0df2aa2c57e4a3049f5494b53f6921c
treec0bd4d10ab6636071b01ba1d0972932752998ccf
parent96aa1e73b3da2252fda883d07cc0600167fc7c79
[TSan][Darwin] Make malloc_size interceptor more robust

Previously we would crash in the TSan runtime if the user program passes
a pointer to `malloc_size()` that doesn't point into app memory.

In these cases, `malloc_size()` should return 0.

For ASan, we fixed a similar issue here:
https://reviews.llvm.org/D15008

Radar-Id: rdar://problem/86213149

Differential Revision: https://reviews.llvm.org/D115947
compiler-rt/lib/tsan/rtl/tsan_mman.cpp
compiler-rt/test/tsan/Darwin/malloc_size.mm