Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsan false positive with new T[0] #257

Closed
ramosian-glider opened this issue Aug 31, 2015 · 2 comments
Closed

lsan false positive with new T[0] #257

ramosian-glider opened this issue Aug 31, 2015 · 2 comments

Comments

@ramosian-glider
Copy link
Member

Originally reported on Google Code with ID 257

If we call "new T[0]", where T is a class with DTOR, 
we'll allocate a 8 byte chunk and store the pointer to the end of this chunk.



% cat leak0.cc 
#include <stdio.h>
struct T {
  ~T() { printf("~T\n"); }
};

T *t;

int main(int argc, char **argv) {
  t = new T[argc - 1];
}
% clang++ -g leak0.cc -fsanitize=address && ASAN_OPTIONS=detect_leaks=1 ./a.out

=================================================================
==18656==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x4558b6 in operator new[](unsigned long) /home/kcc/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:56
    #1 0x46c655 in main /home/kcc/tmp/leak0.cc:9
    #2 0x7f5a8fa6476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226

SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).
% 

Reported by konstantin.s.serebryany on 2014-01-10 09:14:09

@ramosian-glider
Copy link
Member Author

Fixed:  http://llvm.org/viewvc/llvm-project?rev=198932&view=rev

Reported by konstantin.s.serebryany on 2014-01-10 10:57:31

  • Status changed: Fixed

@ramosian-glider
Copy link
Member Author

Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:14:07

  • Labels added: ProjectAddressSanitizer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant