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

Fix missing missing volatile specifiers in CAS operations in GC code

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8u20, 9
    • hotspot
    • gc
    • b140

      GC code uses CAS to exchange values to avoid real locks in a few places.

      This must be done with care, as compilers must be prevented from putting local variables into registers using volatile specifiers. Issues like JDK-8033545 frequently pop up.

      Look through (GC) code that uses these Atomic instructions (Atomic::cmpxchg_ptr, Atomic::cmpxchg) and make sure there might not be problems due to valid compiler optimizations.

      A first look identified at least the following potential places for such issues:

      void G1CollectedHeap::push_dirty_cards_region(HeapRegion* hr) rereading _dirty_cards_region_list
      HeapRegion* G1CollectedHeap::pop_dirty_cards_region(), rereading _dirty_cards_region_list
      PerRegionTable::bulk_free, rereading _free_list
      PerRegionTable*::alloc(HeapRegion* hr), rereading _free_list
      mutableNUMASpace.cpp: 850, rereading top() [end()]
      MutableSpace::cas_allocate(size_t size), rereading top(), end()
      DefNewGeneration::allocate()
      ContiguousSpace::par_allocate_impl() ,rereading top(), end()
      ConcEdenSpace::par_allocate(), probably the OrderAccess::loadload() helps?

      runtime.cpp:1348: head = _named_counters;

            eosterlund Erik Ă–sterlund
            tschatzl Thomas Schatzl
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: