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

IO#seek and tell do not properly handle offsets larger than int32 #3817

Closed
headius opened this issue Apr 20, 2016 · 7 comments
Closed

IO#seek and tell do not properly handle offsets larger than int32 #3817

headius opened this issue Apr 20, 2016 · 7 comments

Comments

@headius
Copy link
Member

headius commented Apr 20, 2016

Environment

JRuby 9.1

Expected Behavior

IO#seek and IO#tell should handle offsets larger than int32 range

Actual Behavior

As seen in #3435, we were not handling the return value of lseek properly, interpreting all negative values as error rather than just -1. That was fixed, but the larger issue is that our native lseek and much of the code that calls it only supports int32 range.

I have a commit coming shortly to fix the main #3435 issue, but this large problem needs to be addressed after 9.1.

@headius headius added this to the JRuby 9.1.1.0 milestone Apr 20, 2016
headius added a commit that referenced this issue Apr 20, 2016
There's a larger bug here, in that our native lseek does not
return a 64-bit value. This results in seeks past the range of a
32-bit int overflowing to negative, which triggered the errors in

See #3817 for remaining work.
@headius
Copy link
Member Author

headius commented Apr 20, 2016

See #3664 for another report partially fixed by #3435.

See jnr/jnr-posix#71 for a PR to fix at least some of these APIs in jnr-posix.

@headius
Copy link
Member Author

headius commented Sep 29, 2016

I had some trouble figuring out how to test this.

@byteit101
Copy link
Member

byteit101 commented Sep 29, 2016

I had a small (well, not file size small, but code small) test case when I reported this on #3664 that could be potentially adapted as a unit test provided you have 3G/5G of disk space

@headius
Copy link
Member Author

headius commented Sep 29, 2016

@byteit101 Yeah it's the file size I'm concerned about. I was able to use /dev/zero to test the jnr-posix fix, but that seems to blow up for me with ruby.

@headius
Copy link
Member Author

headius commented Sep 29, 2016

Oh nevermind...I had reversed seek params. Test coming.

headius added a commit that referenced this issue Sep 29, 2016
eregon pushed a commit to ruby/spec that referenced this issue Oct 29, 2016
@Goltergaul
Copy link

Hi is this issue fixed now on newer jrubies?

@felixbuenemann
Copy link

This is still broken in StringIO on jruby 9.2.9.0:

s = StringIO.new
s.seek(2**31-1)
=> 0
s.seek(2**31)
RangeError (integer 2147483648 too big to convert to `int')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants