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

nsk/share/jvmti/jvmti_tools.cpp: isThreadExpected() leaks memory

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 19
    • Fix Version/s: None
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      After fixing the following bug:

          JDK-8283651 nsk/jvmti/SuspendThread/suspendthrd003 may leak native memory

      I decided to search test/hotspot/jtreg/vmTestbase/nsk/share for
      more problematic uses of JVM/TI GetThreadInfo() and I found
      one more:

      int isThreadExpected(jvmtiEnv *jvmti, jthread thread) {
          static const char *vm_jfr_buffer_thread_name = "VM JFR Buffer Thread";
          static const char *jfr_request_timer_thread_name = "JFR request timer";
          static const char *graal_management_bean_registration_thread_name =
                                                  "HotSpotGraalManagement Bean Registration";
          static const char *graal_compiler_thread_name_prefix = "JVMCI CompilerThread";
          static const size_t prefixLength = strlen(graal_compiler_thread_name_prefix);

          jvmtiThreadInfo threadinfo;
          NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &threadinfo));
              
          if (strcmp(threadinfo.name, vm_jfr_buffer_thread_name) == 0)
              return 0;
          
          if (strcmp(threadinfo.name, jfr_request_timer_thread_name) == 0)
              return 0;
              
          if (strcmp(threadinfo.name, graal_management_bean_registration_thread_name) == 0)
              return 0;

          if ((strlen(threadinfo.name) > prefixLength) &&
               strncmp(threadinfo.name, graal_compiler_thread_name_prefix, prefixLength) == 0)
              return 0;

          return 1;
      }

      The call to JVM/TI GetThreadInfo() returns allocated
      memory in the 'threadinfo.name field and this function
      does not clean that up.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              amenkov Alex Menkov
              Reporter:
              dcubed Daniel Daugherty
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: