forked from OSchip/llvm-project
[lsan] Increase allocator space; minor fixes.
llvm-svn: 184554
This commit is contained in:
parent
b94d5e2d1c
commit
d28c03c03a
|
|
@ -22,11 +22,9 @@
|
|||
|
||||
namespace __lsan {
|
||||
|
||||
static const uptr kMaxAllowedMallocSize =
|
||||
FIRST_32_SECOND_64(3UL << 30, 8UL << 30);
|
||||
|
||||
static const uptr kMaxAllowedMallocSize = 8UL << 30;
|
||||
static const uptr kAllocatorSpace = 0x600000000000ULL;
|
||||
static const uptr kAllocatorSize = 0x10000000000ULL; // 1T.
|
||||
static const uptr kAllocatorSize = 0x40000000000ULL; // 4T.
|
||||
|
||||
struct ChunkMetadata {
|
||||
bool allocated : 8; // Must be first.
|
||||
|
|
@ -79,9 +77,8 @@ void *Allocate(const StackTrace &stack, uptr size, uptr alignment,
|
|||
if (size == 0)
|
||||
size = 1;
|
||||
if (size > kMaxAllowedMallocSize) {
|
||||
Report("WARNING: LeakSanitizer failed to allocate %p bytes\n",
|
||||
(void*)size);
|
||||
return 0;
|
||||
Report("WARNING: LeakSanitizer failed to allocate %zu bytes\n", size);
|
||||
return 0;
|
||||
}
|
||||
void *p = allocator.Allocate(&cache, size, alignment, cleared);
|
||||
RegisterAllocation(stack, p, size);
|
||||
|
|
@ -97,10 +94,9 @@ void *Reallocate(const StackTrace &stack, void *p, uptr new_size,
|
|||
uptr alignment) {
|
||||
RegisterDeallocation(p);
|
||||
if (new_size > kMaxAllowedMallocSize) {
|
||||
Report("WARNING: LeakSanitizer failed to allocate %p bytes\n",
|
||||
(void*)new_size);
|
||||
allocator.Deallocate(&cache, p);
|
||||
return 0;
|
||||
Report("WARNING: LeakSanitizer failed to allocate %zu bytes\n", new_size);
|
||||
allocator.Deallocate(&cache, p);
|
||||
return 0;
|
||||
}
|
||||
p = allocator.Reallocate(&cache, p, new_size, alignment);
|
||||
RegisterAllocation(stack, p, new_size);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ void ScanRangeForPointers(uptr begin, uptr end,
|
|||
uptr pp = begin;
|
||||
if (pp % alignment)
|
||||
pp = pp + alignment - pp % alignment;
|
||||
for (; pp + sizeof(uptr) <= end; pp += alignment) {
|
||||
for (; pp + sizeof(void *) <= end; pp += alignment) {
|
||||
void *p = *reinterpret_cast<void**>(pp);
|
||||
if (!CanBeAHeapPointer(reinterpret_cast<uptr>(p))) continue;
|
||||
void *chunk = PointsIntoChunk(p);
|
||||
|
|
@ -110,7 +110,7 @@ void ScanRangeForPointers(uptr begin, uptr end,
|
|||
if (m.tag() == kIgnored && tag != kReachable) continue;
|
||||
m.set_tag(tag);
|
||||
if (flags()->log_pointers)
|
||||
Report("%p: found %p pointing into chunk %p-%p of size %llu.\n", pp, p,
|
||||
Report("%p: found %p pointing into chunk %p-%p of size %zu.\n", pp, p,
|
||||
chunk, reinterpret_cast<uptr>(chunk) + m.requested_size(),
|
||||
m.requested_size());
|
||||
if (frontier)
|
||||
|
|
@ -278,7 +278,7 @@ void PrintLeakedCb::operator()(void *p) const {
|
|||
LsanMetadata m(p);
|
||||
if (!m.allocated()) return;
|
||||
if (m.tag() == kDirectlyLeaked || m.tag() == kIndirectlyLeaked) {
|
||||
Printf("%s leaked %llu byte object at %p.\n",
|
||||
Printf("%s leaked %zu byte object at %p.\n",
|
||||
m.tag() == kDirectlyLeaked ? "Directly" : "Indirectly",
|
||||
m.requested_size(), p);
|
||||
}
|
||||
|
|
@ -370,15 +370,15 @@ void LeakReport::PrintLargest(uptr max_leaks) {
|
|||
CHECK(leaks_.size() <= kMaxLeaksConsidered);
|
||||
Printf("\n");
|
||||
if (leaks_.size() == kMaxLeaksConsidered)
|
||||
Printf("Too many leaks! Only the first %llu leaks encountered will be "
|
||||
Printf("Too many leaks! Only the first %zu leaks encountered will be "
|
||||
"reported.\n",
|
||||
kMaxLeaksConsidered);
|
||||
if (max_leaks > 0 && max_leaks < leaks_.size())
|
||||
Printf("The %llu largest leak(s):\n", max_leaks);
|
||||
Printf("The %zu largest leak(s):\n", max_leaks);
|
||||
InternalSort(&leaks_, leaks_.size(), IsLarger);
|
||||
max_leaks = max_leaks > 0 ? Min(max_leaks, leaks_.size()) : leaks_.size();
|
||||
for (uptr i = 0; i < max_leaks; i++) {
|
||||
Printf("%s leak of %llu byte(s) in %llu object(s) allocated from:\n",
|
||||
Printf("%s leak of %zu byte(s) in %zu object(s) allocated from:\n",
|
||||
leaks_[i].is_directly_leaked ? "Direct" : "Indirect",
|
||||
leaks_[i].total_size, leaks_[i].hit_count);
|
||||
PrintStackTraceById(leaks_[i].stack_trace_id);
|
||||
|
|
@ -386,7 +386,7 @@ void LeakReport::PrintLargest(uptr max_leaks) {
|
|||
}
|
||||
if (max_leaks < leaks_.size()) {
|
||||
uptr remaining = leaks_.size() - max_leaks;
|
||||
Printf("Omitting %llu more leak(s).\n", remaining);
|
||||
Printf("Omitting %zu more leak(s).\n", remaining);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -398,7 +398,7 @@ void LeakReport::PrintSummary() {
|
|||
allocations += leaks_[i].hit_count;
|
||||
}
|
||||
Printf(
|
||||
"SUMMARY: LeakSanitizer: %llu byte(s) leaked in %llu allocation(s).\n\n",
|
||||
"SUMMARY: LeakSanitizer: %zu byte(s) leaked in %zu allocation(s).\n\n",
|
||||
bytes, allocations);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue