Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5037108

Low-byte of Long Truncated Incorrectly by Bitwise AND

XMLWordPrintable

    • b51
    • x86, sparc
    • linux, solaris_9



      Name: tb29552 Date: 04/23/2004


      FULL PRODUCT VERSION :
      J2SE 1.4.2_04, 1.4.2_01, or 1.5Beta1

      FULL OS VERSION :
      RedHat 9 2.4.20
      RedHat 7.3 2.4.18

      A DESCRIPTION OF THE PROBLEM :
      After running with -server flag for about a minute the following code emits a value that has a low-byte of 0x00 regardless of the input:

           offset & 0xFFFFFFFFL

      The specific context is found in the jCIFS SMB/CIFS client library available at http://jcifs.samba.org/ version 0.8.2 or below jcifs/smb/SmbComWriteAndX.java line ~87.

          writeInt4( offset & 0xFFFFFFFFL, dst, dstIndex );

      where offset is a long and writeInt4 is:

          static void writeInt4( long val, byte[] dst, int dstIndex ) {
              dst[dstIndex++] = (byte)((int)(val >>> 0) & 0xFF);
              dst[dstIndex++] = (byte)((int)(val >>> 8) & 0xFF);
              dst[dstIndex++] = (byte)((int)(val >>> 16) & 0xFF);
              dst[dstIndex++] = (byte)((int)(val >>> 24) & 0xFF);
          }

      Running without -server or removing the unnecessary mask solves the problem.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Download:

      http://jcifs.samba.org/src/jcifs-0.8.21x.jar
      http://home.comcast.net/~miallen1/jcifs/testjcifs.jar

      And run like:

      java -server -cp testjcifs.jar:jcifs-0.8.2x1.jar testjcifs.FullTest smb://server/share/ dom\;user:pass 500

      where server is a SMB/CIFS server. After approxamately 45 seconds the output will transition as follows:

      Thread-0 creating Z1082335691040.tmp
      Thread-0 creating Z1082335691150.tmp
      Thread-42 reading X1082335675290.tmp
      Thread-0 creating Z1082335691440.tmp
      clobbered: 0x5800
      clobbered: 0x5800
      clobbered: 0x5800
      clobbered: 0x5800

      This means that the offset field encoded into the SMB_COM_WRITE_ANDX request with an FID of 0x5800 had the low byte "clobbered" to 0x00.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The expression longValue & 0xFFFFFFFFL should not emit a value with a low byte of 0x00 if the input longValue does not have a 0x00 low byte.
      ACTUAL -
      The expression longValue & 0xFFFFFFFFL emits a value with the low 8 byte set to 0 regardless of whether or not the longValue has a non-0x00 low byte.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Do not use the HotSpot -server option or do not mask a long value with 0xFFFFFFFFL in this way.
      (Incident Review ID: 254855)
      ======================================================================
      ###@###.### 2004-04-23

      For a smaller test case, refer to WI.java, attached to this bug report.

            sdeversunw Steve Dever (Inactive)
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: