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

Win32: Garbage collector fails to mark threads as resumed

    XMLWordPrintable

Details

    • 1.1.4
    • x86
    • windows_nt
    • Not verified

    Description



      Name: wm7046 Date: 05/21/97


      The Java garbage collector at one stage in its lifetime suspends all the threads, and then resumes them later. Unfortunately, it does this in a way that messes up the displayed thread status. Even after they have been resumed, the status is displayed as Suspended until the next time the thread changes status. This means the user trying to debug a hang with the debugger may think threads are suspended when they aren't. It also may mean the debugger might be confused about whether a thread is suspended or not, which might mean it would try to alter stack variables of a running thread, or some such, which could conceivably cause a crash.

      Our Diagnosis

      In order to fix this, it will be necessary to alter the machine-dependent thread structure (to checkpoint the thread's status before it is suspended). This should not impact compatability with earlier versions of the JDK since the structure is so low-level.

      Source Changes to Fix Problem

      1.src\win32\java\include\threads_md.h


      ***************
      *** 64,69 ****
      --- 64,70 ----
            void *(*start_proc)(void *); /* Thread start routine address */
            void *start_parm; /* Thread start routine parameter */
            struct sys_thread *next; /* Next thread in active thread queue */
      + thread_state_t pre_single_state; /* Thread state before sysThreadSingle */ // ARB SAS SAS-BUG-18
        } sys_thread_t;
        
        extern bool_t ThreadsInitialized;



      2.src\win32\java\runtime\threads_md.c


      ***************
      *** 558,564 ****
        static int
        threadSingleHelper(sys_thread_t *tid, void *self)
        {
      ! return tid == self ? SYS_OK : sysThreadSuspend(tid);
        }
        
        /*
      --- 571,582 ----
        static int
        threadSingleHelper(sys_thread_t *tid, void *self)
        {
      ! if (tid == self) return SYS_OK; // ARB SAS SAS-BUG-18
      ! else { // ARB SAS SAS-BUG-18
      ! tid->pre_single_state = tid->state; // ARB SAS SAS-BUG-18
      ! return sysThreadSuspend(tid); // ARB SAS SAS-BUG-18
      ! } // ARB SAS SAS-BUG-18
      ! // return tid == self ? SYS_OK : sysThreadSuspend(tid); // ARB SAS SAS-BUG-18
        }
        
        /*
      ***************
      *** 586,591 ****
      --- 604,610 ----
        static int
        threadMultiHelper(sys_thread_t *tid, void *self)
        {
      + if (tid != self) tid->state = tid->pre_single_state; // ARB SAS SAS-BUG-18
            if (tid == self || ResumeThread(tid->handle) != 0xffffffffUL) {
         return SYS_OK;
            } else {
      ======================================================================

      Attachments

        Activity

          People

            sliangsunw Sheng Liang (Inactive)
            mmma Marvin Ma (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: