Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have a feeling the real fix here is somewhere in jnr.posix since under C rubies, times(2) isn't returning -1 on overflow, this PR is meant to start discussion of a potential fix.
The bug this addresses is here http://linux.die.net/man/2/times, specifically the "Bugs" section. "A limitation of the Linux system call conventions on some architectures (notably i386) means that on Linux 2.6 there is a small time window (41 seconds) soon after boot when times() can return -1, falsely indicating that an error occurred. The same problem can occur when the return value wraps passed the maximum value that can be stored in clock_t."
In C Ruby, the return value of times(2) is never checked(though it probably should be). https://github.com/ruby/ruby/blob/trunk/process.c#L6515
Also, without this patch, the error thrown is ENOENT, or something equally random since there isn't actually an error occurring and being set in kernel space on this call. So, when the old throw occurred from tms being null, it was throwing whatever the last global error value was set to.
I'll stress again that while this keeps 32 bit stuff from crashing, the error is likely in jnr.posix and that our calling conventions from there do not match how Ruby is calling which is causing this issue to manifest.
I consent to having my contributions licensed under EPL, GPLv2, and LGPLv2.