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

Incorrect cmpxchg usage in MetaspaceGC::inc_capacity_until_GC

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 11
    • 11
    • hotspot
    • None
    • gc
    • b16
    • generic
    • generic

        MetaspaceGC::inc_capacity_until_GC presently has

        2420 size_t capacity_until_GC = _capacity_until_GC;
        2421 size_t new_value = capacity_until_GC + v;
          ...
        2428 size_t expected = _capacity_until_GC;
        2429 size_t actual = Atomic::cmpxchg(new_value, &_capacity_until_GC, expected);

        If a different thread were to modify _capacity_until_GC between line 2420 and 2428, that modification could be quietly lost.

        The refetch of _capacity_until_GC at line 2428 is the culprit. It should be removed, and all uses of "expected" should be replaced with "capacity_until_GC" (which should perhaps be renamed "old_value").

              tschatzl Thomas Schatzl
              kbarrett Kim Barrett
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: