Skip to content

Commit

Permalink
Merge branch 'fix/aligned-buffer' into 'master'
Browse files Browse the repository at this point in the history
Fix memory issues in per-thread data

See merge request multicore/drace!43
  • Loading branch information
fmoessbauer committed Jul 11, 2019
2 parents 09e2883 + 80d4a3c commit 9a386f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drace-client/include/aligned-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ namespace drace {
// copy this as value is modified by std::align
size_t space_size = _size_in_bytes;
_mem = dr_thread_alloc(drcontext, _size_in_bytes);
data = (T*)std::align(alignment, capacity, _mem, space_size);
// std::align changes pointer to memspace, hence copy
void * mem_align = _mem;
DR_ASSERT_MSG(
std::align(alignment, capacity, mem_align, space_size) != nullptr,
"could not allocate aligned memory");
data = (T*)mem_align;
DR_ASSERT(((uint64_t)data % alignment) == 0);
}
}
};
}
}
2 changes: 2 additions & 0 deletions drace-client/src/memory-tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ namespace drace {
data->stack.deallocate(drcontext);
data->mem_buf.deallocate(drcontext);

hashtable_delete(&(data->mutex_book));

// free statistics
data->stats->~Statistics();
dr_thread_free(drcontext, data->stats, sizeof(Statistics));
Expand Down

0 comments on commit 9a386f3

Please sign in to comment.