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

JFR: Non-Java threads are not serialized

XMLWordPrintable

    • jfr
    • b16

      Both JMC and the JFR parser reports that some events from non-java threads have a 'null' eventThread.

      I found that the following code fails to checkpoint the non-java threads:
      void JfrThreadConstantSet::serialize(JfrCheckpointWriter& writer) {
        JfrCheckpointThreadClosure tc(writer);
      ...
        JfrNonJavaThreadIterator nonjavathreads;
        while (nonjavathreads.has_next()) {
          tc.do_thread(nonjavathreads.next());
        }
      }

      because the following code only returns the last thread:
      ---
      static NonJavaThread* next_non_java_thread(NonJavaThread::Iterator& iter) {
        NonJavaThread* next = NULL;
        while (!iter.end()) {
          next = iter.current();
          iter.step();
          assert(next != NULL, "invariant");
          if (!thread_inclusion_predicate(next)) {
            continue;
          }
        }
        return next;
      }
      ---

      I've tested with the following code, and then we get the correct thread names:
      ---
      static NonJavaThread* next_non_java_thread(NonJavaThread::Iterator& iter) {
        while (!iter.end()) {
          NonJavaThread* next = iter.current();
          iter.step();
          assert(next != NULL, "invariant");
          if (thread_inclusion_predicate(next)) {
            return next;
          }
        }
        return NULL;
      }
      ---

            stefank Stefan Karlsson
            stefank Stefan Karlsson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: