IO#seek and IO#tell should handle offsets larger than int32 range
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.
Only treate -1 ret from lseek as error. Fixes #3435.
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.
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.
Use lseekLong to get lseek return value. Fixes #3817.
I had some trouble figuring out how to test this.
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
@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.
Oh nevermind...I had reversed seek params. Test coming.
Spec for IO#seek > 2^32.