Advice on finding out the cause of test failure of VarHandleTestAccessBoolean on windows x64

Paul Sandoz paul.sandoz at oracle.com
Fri Aug 12 15:36:25 UTC 2016


Hi,

Please can someone help/advice how to find the cause of a test failure i am observing.

The patch for VarHandles bitwise operations [1] is failing for boolean, the test VarHandleTestAccessBoolean, but only on windows x64. I have observed it can reliably fail in different assertions when testing bitwise ops and AFAICT so far only for C2 (and definitely not in the interpreter).

Here is an example:

  // get and bitwise and
  {
      vh.set(true);

      boolean o = (boolean) vh.getAndBitwiseAnd(false);
      assertEquals(o, true, "getAndBitwiseAnd boolean”);  // <— PASSES for the previous value
      boolean x = (boolean) vh.get();
      assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value”);  // <— FAILS for the updated value, expected false got true
  }


It appears as if the atomic read modify write of “vh.getAndBitwiseAnd" failed and when getting the value (“vh.get”) it reads the previous value.

I don’t know what could be different about the windows x64 platform that such a bug could arise just on that platform.


vh.set/set will defer to Unsafe.put/getBoolean, where as the vh.getAndBitwiseAnd will call:

  @ForceInline
  public final boolean getAndBitwiseAndBoolean(Object o, long offset, boolean mask) {
      return byte2bool(getAndBitwiseAndByte(o, offset, bool2byte(mask)));
  }

  @ForceInline
  public final byte getAndBitwiseAndByte(Object o, long offset, byte mask) {
      byte current;
      do {
          current = getByteVolatile(o, offset);
      } while (!weakCompareAndSwapByteVolatile(o, offset,
                                                current, (byte) (current & mask)));
      return current;
  }

which defers to reading/writing the boolean as the VM byte representation. So there is a mismatch going on between T_BOOLEAN and T_BYTE but i gather that should not be an issue.

If i disable the Unsafe _getByte and _getByteVolatile intrinsics the test passes.

(I have yet to work out how to compile and use hdis on windows x64).

Thanks,
Paul.

[1] http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8161444-vhs-bitwise-atomics/webrev/



More information about the hotspot-dev mailing list