Undefined behavior with interval > 1 second
benbuckman opened this issue · 0 comments
The code to translate interval
(set in microseconds) to a timer is implemented here,
stackprof/ext/stackprof/stackprof.c
Lines 115 to 116 in b886c3c
and (for forks) here,
stackprof/ext/stackprof/stackprof.c
Lines 628 to 629 in b886c3c
it_interval
is a timeval
, documented at https://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html says (emphasis mine),
long int tv_usec
This is the rest of the elapsed time (a fraction of a second), represented as the number of microseconds. It is always less than one million.
What is supposed to happen if interval
(passed to start
or run
) is >= one million?
It looks like the timeval
itself will take that value, but the behavior is undefined.
Should StackProf error if the interval is larger than one million? Or should it split the interval over seconds + microseconds?
Thank you