Harmony
  1. Harmony
  2. HARMONY-6137

[drlvm][concurrent] AtomicLong compare and swap returning wrong indicator

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0M9
    • Component/s: DRLVM
    • Labels:
      None
    • Environment:
      Linux, r761319

      Description

      Consider the following code that exercises AtomLong compare and swap operations:

      AtomicLong atomLong = new AtomicLong(1);
      System.out.println(atomLong.get());
      System.out.println("CAS 1,-4 = " + atomLong.compareAndSet(1, -4));
      System.out.println(atomLong.get());
      System.out.println("CAS -5,1 = " + atomLong.compareAndSet(-5, 1));
      System.out.println(atomLong.get());

      I expect it to print out:
      1
      CAS 1,-4 = true
      -4
      CAS -5,1 = false
      -4

      Since the comparison of --4 and -5 fails.
      However when running that code on harmony r761319 I see

      1
      CAS 1,-4 = true
      -4
      CAS -5,1 = true
      -4

      i.e. the swap is not done, but the method returned true as though it had done the swap.

        Activity

        Hide
        Tim Ellison added a comment -

        The test produces the same (wrong) results on Harmony M8.

        Show
        Tim Ellison added a comment - The test produces the same (wrong) results on Harmony M8.
        Hide
        Nathan Beyer added a comment -

        Was this on x86, x86_64 or Itanium?

        Show
        Nathan Beyer added a comment - Was this on x86, x86_64 or Itanium?
        Hide
        Nathan Beyer added a comment -

        On Ubuntu 8.10 x86_64, I'm not seeing the incorrect output. I'm going to test this out on an x86 machine with the same OS.

        The code for this has all been inlined into the header as inline assembly, for linux x86, linux x86_64, win 32 and win 64 - it's rather messy.

        Show
        Nathan Beyer added a comment - On Ubuntu 8.10 x86_64, I'm not seeing the incorrect output. I'm going to test this out on an x86 machine with the same OS. The code for this has all been inlined into the header as inline assembly, for linux x86, linux x86_64, win 32 and win 64 - it's rather messy.
        Hide
        Tim Ellison added a comment -

        The test is failing for me on Ubuntu 8.10 x86 (Intel Core2 Duo)

        Show
        Tim Ellison added a comment - The test is failing for me on Ubuntu 8.10 x86 (Intel Core2 Duo)
        Hide
        Egor Pasko added a comment -

        hm, works for me as expected on linux_x86_gcc_debug.

        Show
        Egor Pasko added a comment - hm, works for me as expected on linux_x86_gcc_debug.
        Hide
        Egor Pasko added a comment -

        however, "memory" should be in the clobber list, please, try the patch ...

        Show
        Egor Pasko added a comment - however, "memory" should be in the clobber list, please, try the patch ...
        Hide
        Egor Pasko added a comment -

        my cpuinfo is different however: Intel(R) Pentium(R) M processor 2.13GHz

        Show
        Egor Pasko added a comment - my cpuinfo is different however: Intel(R) Pentium(R) M processor 2.13GHz
        Hide
        Tim Ellison added a comment -

        The patch works for me, thanks Egor.

        All concurrent tests pass ok.

        Show
        Tim Ellison added a comment - The patch works for me, thanks Egor. All concurrent tests pass ok.
        Hide
        Egor Pasko added a comment -

        okay resolved

        Show
        Egor Pasko added a comment - okay resolved

          People

          • Assignee:
            Unassigned
            Reporter:
            Tim Ellison
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development