Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7900605

Dynamic Instrumenter never waits for child threads before terminating

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description



      Name: dkR10031 Date: 06/27/2003



      Current edition of the Jcov User Guide contains in
      the section "B.2.2 Dynamic Instrumenter" the description
      of the following feature:
      "-nowaitchild: Don't wait for all threads to complete. Specifies that the
      executor must be terminated immediately after the main() method exits. If
      the option is not specified, then the executor waits for all threads
      spawned by the program to finish."

      However, current implementation of the Dynamic instrumenter
      does not wait for all threads spawned by the program although
      '-nowaitchaild' option is not used while dynamic instrumentation.

      To reproduce this situation please run the following example
      using script below. The test app. run via the Dynamic Instrumenter
      should print out the message "Thread is finished" issued by the child
      thread, but it does not.

       This script contains the next stages:

       1. Compilation of the test source.
       2. Execution of the test to show that program has finished
          all the spawned threads.
       3. Execution of the test using the Dynamic Instrumenter to show
          that spawned thread is not finished ("Thread is finished" line
          is not generated).

      -------------------------- test.java source begin --------------------
      class A extends Thread {

          public void run() {

              System.out.println("Thread is started!");
              try {
                  sleep(5000);
              } catch (InterruptedException ie) {
                  System.out.println("IE:"+ie.getMessage());
              }
              System.out.println("Thread is finished");
          }
      }

      public class test extends Thread {

              public static void main(String[] args) {

                  A a = new A();
                  a.start();
              }
      }
      -------------------------- test.java source end ----------------------
      -------------------------- script begin ------------------------------
      uname -a
      export JCOV_JAR=/export/home/gary/QA.JCOV/ws-jcov/test.linux-x86/lib/jcov.jar
      export TESTED_JAVA=/net/novo172/export/home/java/dest/jdk1.4.0-b92/linux-i386/bin/java
      export TESTED_JAVAC=/net/novo172/export/home/java/dest/jdk1.4.0-b92/linux-i386/bin/javac

      # Setting the classpath
      CLASSPATH=/export/home/gary/QA.JCOV/ws-jcov/test.linux-x86/lib/jcov.jar
      CLASSPATH=${CLASSPATH}:.
      export CLASSPATH

      # Compile the test programs
      echo 'Compilation begin'
      $TESTED_JAVAC -Xjcov test.java
      echo 'Compilation end'

      # Stardard execution of the test class using java
      echo "---- begin of the output-1 of the test class executed by the java ----"
      $TESTED_JAVA test
      echo "---- end of the output-1 of the test class executed by the java ------"
      # Execute the program with the Dynamic Instrumentor
      # without the -nowaitchild
      echo "---- begin of the output generated by the Dynamic Instrumenter ----"
      $TESTED_JAVA com.sun.tdk.jcov.collect.RunMain -savebefore=java.lang.System.exit test
      echo "---- end of the output generated by the Dynamic Instrumenter ------"
      -------------------------- script end --------------------------------
      -------------------------- script output begin -----------------------
      [gary@linux-11 #xxxxxxxx(Dynamic instrumenter don't wait any child's)]#
      ./run.ksh
      Linux linux-11 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux
      Compilation begin
      Compilation end
      ---- begin of the output-1 of the test class executed by the java ----
      Thread is started!
      Thread is finished
      ---- end of the output-1 of the test class executed by the java ------
      ---- begin of the output generated by the Dynamic Instrumenter ----
      Thread is started!
      ---- end of the output generated by the Dynamic Instrumenter ------
      -------------------------- script output end -------------------------
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            afedorch Alexey Fedorchenko (Inactive)
            Reporter:
            klooney Kevin Looney (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: