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

G1 incorrectly updates scan_top for collection set regions during preparation of evacuation

XMLWordPrintable

    • gc
    • b20

      G1 incorrectly updates scan_top for collection set regions during preparation of evacuation because of this code applied to all regions after clearing the scan_top array to NULL values:

      void G1RemSet::prepare_region_for_scan(HeapRegion* region) {
        uint hrm_index = region->hrm_index();

        if (region->is_old_or_humongous_or_archive()) {
          _scan_state->set_scan_top(hrm_index, region->top());
        } else {
          assert(region->in_collection_set() || region->is_free(),
                 "Should only be free or in the collection set at this point %s", region->get_type_str());
          assert(_scan_state->scan_top(hrm_index) == NULL, "must be");
        }
      }

      i.e. the first condition applies to all regions, so also setting the collection set region's scan_top to top() of that region.

      There are no other drawbacks as we filter out collection set regions for scanning the cards elsewhere. It's only awkward when during debugging you notice that a collection set region has a non-NULL scan_top.

      Also future code might rely on that the value of scan_top is as "expected".

            tschatzl Thomas Schatzl
            tschatzl Thomas Schatzl
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: