Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ddtrace/profiling/collector/_memalloc_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ memalloc_heap_track(uint16_t max_nframe, void* ptr, size_t size)
if (global_heap_tracker.allocated_memory < global_heap_tracker.current_sample_size)
return false;

/* Cannot add more sample */
if (global_heap_tracker.allocs.count >= TRACEBACK_ARRAY_MAX_COUNT)
/* Check if we can add more samples: the sum of the freezer + alloc tracker
cannot be greater than what the alloc tracker can handle: when the alloc
tracker is thawed, all the allocs in the freezer will be moved there!*/
if ((global_heap_tracker.freezer.allocs.count + global_heap_tracker.allocs.count) >= TRACEBACK_ARRAY_MAX_COUNT)
return false;

traceback_t* tb = memalloc_get_traceback(max_nframe, ptr, global_heap_tracker.allocated_memory);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fix a possible bug in the heap memory profiler that could trigger an
overflow when too many allocations were being tracked.