gopalshankar / address-sanitizer

Automatically exported from code.google.com/p/address-sanitizer
0 stars 0 forks source link

Allocator cache is flushed in a wrong place. #233

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently malloc cache is flushed long before the thread actually finishes:

thread_return_t AsanThread::ThreadStart(uptr os_id) {
...
  thread_return_t res = start_routine_(arg_);
  malloc_storage().CommitBack();
  if (flags()->use_sigaltstack) UnsetAlternateSignalStack();
...
}

void AsanThread::Destroy() {
...
  asanThreadRegistry().FinishThread(tid());
  FlushToDeadThreadStats(&stats_);
...
}

malloc_storage().CommitBack() (and UnsetAlternateSignalStack) must be called 
right before asanThreadRegistry().FinishThread(tid()).
Otherwise all memory freed in between is leaked.

Original issue reported on code.google.com by dvyu...@google.com on 18 Oct 2013 at 2:21

GoogleCodeExporter commented 9 years ago
That was quite a major leak actually. 
Fixed in http://llvm.org/viewvc/llvm-project?view=revision&revision=194572

Original comment by konstant...@gmail.com on 13 Nov 2013 at 1:32

GoogleCodeExporter commented 9 years ago
Sorry, this got stuck in my queue. :(

Original comment by earth...@chromium.org on 13 Nov 2013 at 1:34