WorkQueue::push is missing an acquire-fence

XMLWordPrintable

        We discovered that on some weaker memory consistency architectures (read aarch64, etc) a read with acquire-fence is necessary in order to correctly observe an element being present in WorkQueue::push().

        Unfortunately it is not feasible to add a regression test for this, as it very rarely manifests.

        Diffing against https://github.com/openjdk/jdk25u/blob/master/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java

        ```
        diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
        index a7821921bc9..cdc5e0b9ea6 100644
        --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
        +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
        @@ -1297,7 +1297,7 @@ final void push(ForkJoinTask<?> task, ForkJoinPool pool, boolean internal) {
                             unlockPhase();
                         if (room < 0)
                             throw new RejectedExecutionException("Queue capacity exceeded");
        - if ((room == 0 || a[m & (s - pk)] == null) &&
        + if ((room == 0 || U.getReferenceAcquire(a, slotOffset(m & (s - pk))) == null) &&
                             pool != null)
                             pool.signalWork(); // may have appeared empty
                     }
        ```

              Assignee:
              Viktor Klang
              Reporter:
              Viktor Klang
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: