Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

FileInputStream.skip() is broken in Linux (32-bit) on large files

Thread view: 
chrism778@gmail.com - 11 Sep 2007 19:04 GMT
The skip() method appears to be broken in the Java 1.5.05 JVM for
kernel 2.6.9 of Linux (32-bit) when you pass in a value larger than
Integer.MAX_VALUE.  I keep getting an "IOException: Invalid Argument"
when trying to skip more than Integer.MAX_VALUE bytes in a file larger
than Integer.MAX_VALUE.

This method works fine in Windows XP (32-bit) against the exact same
large files.  I also tried a newer JVM (1.5.12), but had the same
problem.

Does anyone know of a workaround or fix for this?  Thanks.

- Chris
chrism778@gmail.com - 11 Sep 2007 20:03 GMT
On Sep 11, 2:04 pm, chrism...@gmail.com wrote:
> The skip() method appears to be broken in the Java 1.5.05 JVM for
> kernel 2.6.9 of Linux (32-bit) when you pass in a value larger than
[quoted text clipped - 9 lines]
>
> - Chris

Turns out the problem was with the mount we were using to connect from
Linux to a Windows file system.  We were using smbfs which only
supports 2GB files.  Once we switched to cifs the problem went away.
Roedy Green - 12 Sep 2007 02:38 GMT
>The skip() method appears to be broken in the Java 1.5.05 JVM for
>kernel 2.6.9 of Linux (32-bit) when you pass in a value larger than
>Integer.MAX_VALUE.

are you by any chance failing to append a trailing L to your literal?
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Lew - 12 Sep 2007 03:45 GMT
>> The skip() method appears to be broken in the Java 1.5.05 JVM for
>> kernel 2.6.9 of Linux (32-bit) when you pass in a value larger than
>> Integer.MAX_VALUE.
>
> are you by any chance failing to append a trailing L to your literal?

There would've been a compiler error, no?

From the JLS:
> The largest decimal literal of type int is 2147483648 (231).
> All decimal literals from 0 to 2147483647 may appear anywhere
> an int literal may appear, but the literal 2147483648 may appear
> only as the operand of the unary negation operator -.

Signature

Lew

Roedy Green - 12 Sep 2007 16:51 GMT
>There would've been a compiler error, no?

It may be fixed now, but there was a time when long literals without
the L were quietly truncated on the high end.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Esmond Pitt - 14 Sep 2007 07:46 GMT
> It may be fixed now, but there was a time when long literals without
> the L were quietly truncated on the high end.

It was fixed in about 1998.
Lew - 14 Sep 2007 13:33 GMT
>> It may be fixed now, but there was a time when long literals without
>> the L were quietly truncated on the high end.
>
> It was fixed in about 1998.

Nevertheless, Rudy's right that one should use the L for long literals.  This
is especially true for values near (long) INT_MAX or (long) INT_MIN.  But why
try to remember when you must use 'L' and when it's optional, or force code
maintainers to?  Just use it whenever you intend a long literal.

Signature

Lew

Andrew Thompson - 14 Sep 2007 14:04 GMT
>Nevertheless, Rudy's ..

<grin>
Eye Haight spell chequers.
</grin>

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Lew - 14 Sep 2007 14:35 GMT
>> Nevertheless, Rudy's ..
>
> <grin>
> Eye Haight spell chequers.
> </grin>

Yes, I am really, really, really sorry about that.

Signature

Lew

Lew - 14 Sep 2007 13:35 GMT
>> It may be fixed now, but there was a time when long literals without
>> the L were quietly truncated on the high end.
>
> It was fixed in about 1998.

Nevertheless, Roedy's right that one should use the L for long literals.  This
is especially true for values near (long) INT_MAX or (long) INT_MIN.  But why
try to remember when you must use 'L' and when it's optional, or force code
maintainers to?  Just use it whenever you intend a long literal.

Signature

Lew

My first, now canceled, post of this message misspelled Roedy's name.  I'm
sorry, Roedy.  I was thinking the right way, but typed the wrong way.

Esmond Pitt - 14 Sep 2007 13:56 GMT
> Nevertheless, ... one should use the L for long  literals.

as the compiler has been forcing you to do since 1998.
Roedy Green - 15 Sep 2007 20:28 GMT
>Nevertheless, Roedy's right that one should use the L for long literals.  This
>is especially true for values near (long) INT_MAX or (long) INT_MIN.

The problem I get nailed on every once is a while is comparing
Integer.MAX_VALUE. As soon as you start doing arithmetic or
comparisons in values in that range, cast to longs, on  use
MAX_VALUE/2 if all you wanted was "a very large value, larger than any
that would occur in "nature""
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

chrism778@gmail.com - 12 Sep 2007 13:33 GMT
On Sep 11, 9:38 pm, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> On Tue, 11 Sep 2007 11:04:14 -0700, chrism...@gmail.com wrote, quoted
> or indirectly quoted someone who said :
[quoted text clipped - 7 lines]
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

Nope.  Eclipse wouldn't allow that anyway. :)

P.S. You have a very helpful website (mindprod.com)!  I've been a
visitor for years.
Andrew Thompson - 12 Sep 2007 05:30 GMT
>The skip() method appears to be broken in the Java 1.5.05 JVM for
>kernel 2.6.9 of Linux (32-bit) when you pass in a value larger than
>Integer.MAX_VALUE.  I keep getting an "IOException: Invalid Argument"
>when trying to skip more than Integer.MAX_VALUE bytes in a file larger
>than Integer.MAX_VALUE.
...
>Does anyone know of a workaround or fix for this?  

I note you had found a work-around for the current
installation, by changing the FS.  Assuming the FS
were not open for adjustment to this apps. needs,
I was wondering if this simple little hack might work.

..
 long target = Integer.MAX_VALUE*5l + 7l;
 while ( target>Integer.MAX_VALUE ) {
   fis.skip( Integer.MAX_VALUE );
   target -= Integer.MAX_VALUE;
 }
 fis.skip( target );
..

A test by the OP under the original conditions would
be interesting, but I am also interested in hearing
theoretical comments.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

chrism778@gmail.com - 12 Sep 2007 13:24 GMT
> chrism...@gmail.com wrote:
> >The skip() method appears to be broken in the Java 1.5.05 JVM for
[quoted text clipped - 27 lines]
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1

Andrew,

I had already tried that and it didn't work.  The second you exceed
2GB (even if it doesn't happen until your second call to skip()) you
get the same error.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.