Closed GoogleCodeExporter closed 9 years ago
I don't think we can do anything here.
new[] for non-trivially-destructible types doesn't return you the pointer to
the allocated block of memory. It returns you a pointer *inside* the block of
allocated memory (which is what ASan report tells you), as the beginning of
allocated block contains an array cookie. I'm pretty sure malloc_usable_size()
is not guaranteed to
work in this case. It actually doesn't work without ASan. If I add
printf("%zu\n", malloc_usable_size(foo));
to your example I observe:
$ ./bin/clang++ tmp/test.cc ; ./a.out
18446744073709551608
Original comment by samso...@google.com
on 24 Jun 2015 at 9:13
Makes sense, thanks for the detailed explanation.
Original comment by ade...@gmail.com
on 24 Jun 2015 at 9:40
We could scan shadow for heap left redzone. But reporting this issue with new
is probably a good thing.
Original comment by tetra20...@gmail.com
on 25 Jun 2015 at 8:00
Adding Project:AddressSanitizer as part of GitHub migration.
Original comment by ramosian.glider@gmail.com
on 30 Jul 2015 at 9:14
Original issue reported on code.google.com by
ade...@gmail.com
on 24 Jun 2015 at 8:59