What steps will reproduce the problem?
1. Compile the testcase below one with ASan and one with TSan
2. Observe that with TSan, two tests fail.
What is the expected output? What do you see instead?
With ASan, all tests pass (this test is part of the ASan test suite). With
TSan, the tests fail because the function always returns 0. Note that with
neither ASan nor TSan, the tests also fail because malloc_usable_size returns
sizes larger than the expected ones (which is allowed).
What version of the product are you using? On what operating system?
llvm/clang/compiler-rt r175901 on Ubuntu Linux 12.04 LTS
Testcase to reproduce the problem:
#include <cstdio>
#include <cstdlib>
#include <malloc.h>
int main() {
const size_t kArraySize = 100;
char *array = (char*)malloc(kArraySize);
int *int_ptr = new int;
size_t mus_null = malloc_usable_size(NULL);
if (mus_null != 0) {
fprintf(stderr, "Test failed: malloc_usable_size(NULL) returned %lu, expected 0\n", mus_null);
}
size_t mus_arr = malloc_usable_size(array);
if (mus_arr != kArraySize) {
fprintf(stderr, "Test failed: malloc_usable_size(array) returned %lu, expected %lu\n", mus_arr, kArraySize);
}
size_t mus_ptr = malloc_usable_size(int_ptr);
if (mus_ptr != sizeof(int)) {
fprintf(stderr, "Test failed: malloc_usable_size(int_ptr) returned %lu, expected %lu\n", mus_ptr, sizeof(int));
}
return 0;
}
Original issue reported on code.google.com by decoder...@googlemail.com on 22 Feb 2013 at 9:23
Original issue reported on code.google.com by
decoder...@googlemail.com
on 22 Feb 2013 at 9:23