[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 } ```
Loading
Please sign in to comment