N
nobrow
This one is just fantastic! I have a large binary file being processed
in Java. After insertion of much debugging code, and with a hex editor
I have discovered the following behaviour.
At some point the DataInputStream (dis) which I am using to read the
file hits the following sequence of bytes;
.... 05 00 00 00 00 00 03 07 C0 08 05 24 18 4D 11 E0 A8 ...
The following sequence of methods are executed;
dis.read() ... gives 5 (0x5) ... fine
dis.readLong() ... gives 198592 (0x00000000000307C0) ... fine
dis.readInt() ... gives 134554648 (0x08052418) ... fine
dis.readInt() ... gives 407704032 (0x184D11E0) ... WTF!?
Notice anything about that last one? ... The last byte read by the
preceeding readInt() is being read as the first byte by this
readInt()!!!!!
The really annoying thing is that its intermittent. Happens every time
today. Worked fine yesterday. Happened every time the day before. There
is nothing unusal about my system. No background processes that could
be getting involved. No changes in it from day to day.
I know posting code would be a good move but the program is quite
involved and difficult to chop down into a minimal example. Suffice it
to say that there is nothing complicated about the offending portion of
the code. The DataInputStream is not being shared across threads or
anything, and those methods are executed in succession, with nothing
else happening in between.
Am running on Linux.
$ java -version
java version "1.4.2_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)
Seriously! Whats that about? Anyone ever seen anything like this before?
in Java. After insertion of much debugging code, and with a hex editor
I have discovered the following behaviour.
At some point the DataInputStream (dis) which I am using to read the
file hits the following sequence of bytes;
.... 05 00 00 00 00 00 03 07 C0 08 05 24 18 4D 11 E0 A8 ...
The following sequence of methods are executed;
dis.read() ... gives 5 (0x5) ... fine
dis.readLong() ... gives 198592 (0x00000000000307C0) ... fine
dis.readInt() ... gives 134554648 (0x08052418) ... fine
dis.readInt() ... gives 407704032 (0x184D11E0) ... WTF!?
Notice anything about that last one? ... The last byte read by the
preceeding readInt() is being read as the first byte by this
readInt()!!!!!
The really annoying thing is that its intermittent. Happens every time
today. Worked fine yesterday. Happened every time the day before. There
is nothing unusal about my system. No background processes that could
be getting involved. No changes in it from day to day.
I know posting code would be a good move but the program is quite
involved and difficult to chop down into a minimal example. Suffice it
to say that there is nothing complicated about the offending portion of
the code. The DataInputStream is not being shared across threads or
anything, and those methods are executed in succession, with nothing
else happening in between.
Am running on Linux.
$ java -version
java version "1.4.2_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)
Seriously! Whats that about? Anyone ever seen anything like this before?