Skip to content
Unverified Commit 4effda09 authored by Chen Zheng's avatar Chen Zheng Committed by GitHub
Browse files

[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
}
```
parent bcf07cef
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment