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

G1Analytics uses uninitialized fields

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 10
    • Fix Version/s: 10
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
      gc
    • Resolved In Build:
      b34

      Description

      Both _recent_avg_pause_time_ratio and _last_pause_time_ratio are missing from the initialization list, and in effect will leave these fields uninitialized.

      The following is a potential use before initialization situation:
      ---
              {
                size_t expand_bytes = _heap_sizing_policy->expansion_amount(); // USED HERE
                if (expand_bytes > 0) {
                  size_t bytes_before = capacity();
                  // No need for an ergo logging here,
                  // expansion_amount() does this when it returns a value > 0.
                  double expand_ms;
                  if (!expand(expand_bytes, _workers, &expand_ms)) {
                    // We failed to expand the heap. Cannot do anything about it.
                  }
                  g1_policy()->phase_times()->record_expand_heap_time(expand_ms);
                }
              }

              // We redo the verification but now wrt to the new CSet which
              // has just got initialized after the previous CSet was freed.
              _cm->verify_no_cset_oops();

              // This timing is only used by the ergonomics to handle our pause target.
              // It is unclear why this should not include the full pause. We will
              // investigate this in CR 7178365.
              double sample_end_time_sec = os::elapsedTime();
              double pause_time_ms = (sample_end_time_sec - sample_start_time_sec) * MILLIUNITS;
              size_t total_cards_scanned = per_thread_states.total_cards_scanned();
              g1_policy()->record_collection_pause_end(pause_time_ms, total_cards_scanned, heap_used_bytes_before_gc); // SET HERE

      ---
      do_collection_pause_at_safepoint
        record_collection_pause_end
          compute_pause_time_ratio
            sets _recent_avg_pause_time_ratio

      ---
      do_collection_pause_at_safepoint
        expansion_amount
          reads _recent_avg_pause_time_ratio
          _recent_avg_pause_time_ratio(),
          _last_pause_time_ratio()

        Attachments

          Activity

            People

            Assignee:
            ehelin Erik Helin
            Reporter:
            stefank Stefan Karlsson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: