Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined behavior with interval > 1 second #125

Open
benbuckman opened this issue Nov 11, 2019 · 0 comments
Open

Undefined behavior with interval > 1 second #125

benbuckman opened this issue Nov 11, 2019 · 0 comments

Comments

@benbuckman
Copy link
Contributor

The code to translate interval (set in microseconds) to a timer is implemented here,

timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = NUM2LONG(interval);

and (for forks) here,
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = NUM2LONG(_stackprof.interval);

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

benbuckman added a commit to benbuckman/stackprof that referenced this issue Nov 11, 2019
albertarcuri pushed a commit to albertarcuri/stackprof that referenced this issue Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant