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

MultiThreadedRefCounter should not use relaxed atomic decrement

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 18
    • Fix Version/s: 18
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
      jfr
    • Resolved In Build:
      b27

      Description

      JDK-8275730 changed MultiThreadedRefCounter to use relaxed atomics to increment and decrement the counter. The rationale was that it's "just a counter". But that isn't true; it's a reference counter, which has additional semantics that impose stronger requirements on the atomic operations. In particular, the decrement operation must be a release operation, and must be followed by an acquire barrier when the counter reaches zero. This is needed to ensure any possible accesses in one thread "happen before" deleting the object in a different thread. Without those barriers all kinds of bad data races are possible.

      https://www.boost.org/doc/libs/1_57_0/doc/html/atomic/usage_examples.html#boost_atomic.usage_examples.example_reference_counters

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mgronlun Markus Grönlund
              Reporter:
              kbarrett Kim Barrett
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: