[all-commits] [llvm/llvm-project] 4effda: [ASan] return 0 for current allocated bytes if mal...
Chen Zheng via All-commits
all-commits at lists.llvm.org
Tue Sep 26 10:48:10 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 4effda09d897c165253118dae8b7580d9d276048
https://github.com/llvm/llvm-project/commit/4effda09d897c165253118dae8b7580d9d276048
Author: Chen Zheng <czhengsz at cn.ibm.com>
Date: 2023-09-26 (Tue, 26 Sep 2023)
Changed paths:
M compiler-rt/lib/asan/asan_stats.cpp
M compiler-rt/test/asan/TestCases/Posix/current_allocated_bytes.cpp
Log Message:
-----------
[ASan] return 0 for current allocated bytes if malloc/free are never happend (#67394)
This is found during address sanitizer enablement on AIX.
On platforms that has no malloc/free calls before user's malloc/free
calls, `__sanitizer_get_current_allocated_bytes()` should return 0.
Otherwise the case like
`compiler-rt/test/sanitizer_common/TestCases/allocator_interface.cpp`
will fail at below scenario:
```
void Test(int size) {
auto allocated_bytes_before = __sanitizer_get_current_allocated_bytes();
int *p = (int *)malloc(size);
assert(__sanitizer_get_current_allocated_bytes() >=
size + allocated_bytes_before); // if allocated_bytes_before is 1, this assert will fail. allocated_bytes_before should be 0
}
```
More information about the All-commits
mailing list