-
Notifications
You must be signed in to change notification settings - Fork 133
Description
Currently the buffer is only reset after a sample is recorded:
stackprof/ext/stackprof/stackprof.c
Lines 680 to 688 in e263746
// record the sample previously buffered by stackprof_buffer_sample | |
static void | |
stackprof_record_buffer(void) | |
{ | |
stackprof_record_sample_for_stack(_stackprof.buffer_count, _stackprof.buffer_time.timestamp_usec, _stackprof.buffer_time.delta_usec); | |
// reset the buffer | |
_stackprof.buffer_count = 0; | |
} |
However, when stopping stackprof, we may skip this:
stackprof/ext/stackprof/stackprof.c
Lines 714 to 719 in e263746
stackprof_job_record_buffer(void *data) | |
{ | |
if (!_stackprof.running) return; | |
stackprof_record_buffer(); | |
} |
This could leave a sample buffered, or for stackprof to believe it has a sample still buffered anyways. Since we never reset this counter between stackprof runs in stackprof_results
, it is thus possible that this could bleed state into a future invocation of stackprof
At minimum, I think we must reset this counter as part of stackprof_results
, following the existing idiom of resetting values there during reporting. A better behaviour would probably be to pop any buffered but not recorded data off as well, rather than discarding it outright