8211909: JDWP Transport Listener: dt_socket thread crash

Mon, 22 Oct 2018 02:50:45 -0400

author
fmatte
date
Mon, 22 Oct 2018 02:50:45 -0400
changeset 9511
e33aa14a0d8b
parent 9510
be27fec0948c
child 9512
992120803410

8211909: JDWP Transport Listener: dt_socket thread crash
Reviewed-by: dholmes, jcbeyler

src/share/vm/prims/jvmtiEnv.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/prims/jvmtiEnv.cpp	Fri Oct 19 20:42:34 2018 -0700
     1.2 +++ b/src/share/vm/prims/jvmtiEnv.cpp	Mon Oct 22 02:50:45 2018 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -727,7 +727,7 @@
    1.11    thread_objs = NEW_RESOURCE_ARRAY(Handle, nthreads);
    1.12    NULL_CHECK(thread_objs, JVMTI_ERROR_OUT_OF_MEMORY);
    1.13  
    1.14 -  for (int i=0; i < nthreads; i++) {
    1.15 +  for (int i = 0; i < nthreads; i++) {
    1.16      thread_objs[i] = Handle(tle.get_threadObj(i));
    1.17    }
    1.18  
    1.19 @@ -952,16 +952,14 @@
    1.20    Handle context_class_loader;
    1.21    bool          is_daemon;
    1.22  
    1.23 -  { MutexLocker mu(Threads_lock);
    1.24 -
    1.25 -    name = Handle(current_thread, java_lang_Thread::name(thread_obj()));
    1.26 -    priority = java_lang_Thread::priority(thread_obj());
    1.27 -    thread_group = Handle(current_thread, java_lang_Thread::threadGroup(thread_obj()));
    1.28 -    is_daemon = java_lang_Thread::is_daemon(thread_obj());
    1.29 -
    1.30 -    oop loader = java_lang_Thread::context_class_loader(thread_obj());
    1.31 -    context_class_loader = Handle(current_thread, loader);
    1.32 -  }
    1.33 +  name = Handle(current_thread, java_lang_Thread::name(thread_obj()));
    1.34 +  priority = java_lang_Thread::priority(thread_obj());
    1.35 +  thread_group = Handle(current_thread, java_lang_Thread::threadGroup(thread_obj()));
    1.36 +  is_daemon = java_lang_Thread::is_daemon(thread_obj());
    1.37 +
    1.38 +  oop loader = java_lang_Thread::context_class_loader(thread_obj());
    1.39 +  context_class_loader = Handle(current_thread, loader);
    1.40 +
    1.41    { const char *n;
    1.42  
    1.43      if (name() != NULL) {
    1.44 @@ -1193,14 +1191,11 @@
    1.45    bool is_daemon;
    1.46    ThreadPriority max_priority;
    1.47  
    1.48 -  { MutexLocker mu(Threads_lock);
    1.49 -
    1.50 -    name         = typeArrayHandle(current_thread,
    1.51 -                                   java_lang_ThreadGroup::name(group_obj()));
    1.52 -    parent_group = Handle(current_thread, java_lang_ThreadGroup::parent(group_obj()));
    1.53 -    is_daemon    = java_lang_ThreadGroup::is_daemon(group_obj());
    1.54 -    max_priority = java_lang_ThreadGroup::maxPriority(group_obj());
    1.55 -  }
    1.56 +  name         = typeArrayHandle(current_thread,
    1.57 +                                 java_lang_ThreadGroup::name(group_obj()));
    1.58 +  parent_group = Handle(current_thread, java_lang_ThreadGroup::parent(group_obj()));
    1.59 +  is_daemon    = java_lang_ThreadGroup::is_daemon(group_obj());
    1.60 +  max_priority = java_lang_ThreadGroup::maxPriority(group_obj());
    1.61  
    1.62    info_ptr->is_daemon    = is_daemon;
    1.63    info_ptr->max_priority = max_priority;
    1.64 @@ -1240,8 +1235,8 @@
    1.65  
    1.66    Handle group_hdl(current_thread, group_obj);
    1.67  
    1.68 -  { MutexLocker mu(Threads_lock);
    1.69 -
    1.70 +  {
    1.71 +    ObjectLocker ol(group_hdl, current_thread);
    1.72      nthreads = java_lang_ThreadGroup::nthreads(group_hdl());
    1.73      ngroups  = java_lang_ThreadGroup::ngroups(group_hdl());
    1.74  
    1.75 @@ -1249,7 +1244,7 @@
    1.76        objArrayOop threads = java_lang_ThreadGroup::threads(group_hdl());
    1.77        assert(nthreads <= threads->length(), "too many threads");
    1.78        thread_objs = NEW_RESOURCE_ARRAY(Handle,nthreads);
    1.79 -      for (int i=0, j=0; i<nthreads; i++) {
    1.80 +      for (int i = 0, j = 0; i < nthreads; i++) {
    1.81          oop thread_obj = threads->obj_at(i);
    1.82          assert(thread_obj != NULL, "thread_obj is NULL");
    1.83          JavaThread *javathread = java_lang_Thread::thread(thread_obj);
    1.84 @@ -1266,15 +1261,14 @@
    1.85        objArrayOop groups = java_lang_ThreadGroup::groups(group_hdl());
    1.86        assert(ngroups <= groups->length(), "too many threads");
    1.87        group_objs = NEW_RESOURCE_ARRAY(Handle,ngroups);
    1.88 -      for (int i=0; i<ngroups; i++) {
    1.89 +      for (int i = 0; i < ngroups; i++) {
    1.90          oop group_obj = groups->obj_at(i);
    1.91          assert(group_obj != NULL, "group_obj != NULL");
    1.92          group_objs[i] = Handle(current_thread, group_obj);
    1.93        }
    1.94      }
    1.95 -  }
    1.96 -
    1.97 -  // have to make global handles outside of Threads_lock
    1.98 +  } // ThreadGroup unlocked here
    1.99 +
   1.100    *group_count_ptr  = ngroups;
   1.101    *thread_count_ptr = nthreads;
   1.102    *threads_ptr     = new_jthreadArray(nthreads, thread_objs);
   1.103 @@ -2979,7 +2973,7 @@
   1.104        // objects that are locked.
   1.105        int r;
   1.106        intptr_t recursion = rmonitor->recursions();
   1.107 -      for (intptr_t i=0; i <= recursion; i++) {
   1.108 +      for (intptr_t i = 0; i <= recursion; i++) {
   1.109          r = rmonitor->raw_exit(thread);
   1.110          assert(r == ObjectMonitor::OM_OK, "raw_exit should have worked");
   1.111          if (r != ObjectMonitor::OM_OK) {  // robustness
   1.112 @@ -3395,7 +3389,7 @@
   1.113        strcpy(*tmp_value, key);
   1.114      } else {
   1.115        // clean up previously allocated memory.
   1.116 -      for (int j=0; j<i; j++) {
   1.117 +      for (int j = 0; j < i; j++) {
   1.118          Deallocate((unsigned char*)*property_ptr+j);
   1.119        }
   1.120        Deallocate((unsigned char*)property_ptr);

mercurial