Processdottimesfix #1507

Merged
merged 1 commit into from Feb 26, 2014

Projects

None yet

2 participants

@jhspaybar

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.

@jhspaybar

Whoops, this is line 6505 now, probably need a better way to link this.

@headius headius merged commit 378e659 into jruby:jruby-1_7 Feb 26, 2014

1 check failed

Details default The Travis CI build could not complete due to an error
@headius headius added this to the JRuby 1.7.12 milestone Feb 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment