Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 395 by [email protected]: pointer not owned error when calling malloc_usable_size() on array of structs with destructors
https://code.google.com/p/address-sanitizer/issues/detail?id=395

adar@adar-ThinkPad-T540p:/tmp$ cat test.cc
#include <malloc.h>

struct Blah {
  ~Blah() {}
  long long a;
};

int main(int argc, char* argv[]) {
  Blah* foo = new Blah[1];
  malloc_usable_size(foo);
  delete [] foo;
  return 0;
}

adar@adar-ThinkPad-T540p:/tmp$ ~/Source/llvm-build/bin/clang++ -fsanitize=address -o test test.cc
adar@adar-ThinkPad-T540p:/tmp$ ./test
=================================================================
==16156==ERROR: AddressSanitizer: attempting to call malloc_usable_size() for pointer which is not owned: 0x60200000eff8
    #0 0x4b4ed0  (/tmp/test+0x4b4ed0)
    #1 0x4e36e5  (/tmp/test+0x4e36e5)
    #2 0x7f4bcff8ba3f  (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
    #3 0x418fd8  (/tmp/test+0x418fd8)

0x60200000eff8 is located 8 bytes inside of 16-byte region [0x60200000eff0,0x60200000f000)
allocated by thread T0 here:
    #0 0x4e0ab0  (/tmp/test+0x4e0ab0)
    #1 0x4e36b7  (/tmp/test+0x4e36b7)
    #2 0x7f4bcff8ba3f  (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)

SUMMARY: AddressSanitizer: bad-malloc_usable_size (/tmp/test+0x4b4ed0)
==16156==ABORTING


This is using clang from the top of trunk, though I've reproduced it with clang 3.6 as well.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to