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

demo/jvmti/heapTracker: argument maxDump not parsed correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 5.0
    • core-svc
    • b40
    • sparc
    • solaris_9

      FULL PRODUCT VERSION :
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Server VM (build 1.5.0_01-b08, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      SunOS salix 5.9 Generic_117171-12 sun4u sparc SUNW,Sun-Fire-280R

        Bug is valid on any OS, seee attached Patch.

      A DESCRIPTION OF THE PROBLEM :
        Bug in commandline option parsing in heapTracker demo jvmti agent:

      File $JAVA_HOME/demo/jvmti/heapTracker/src/heapTracker.c with version:

       * @(#)heapTracker.c 1.8 04/09/24

      See Patch under "Workaround" below.

      Using -agentlib:heapTracker=maxDump=<number> on the commandline will be parsed by heapTracker.c ny calling get_token with token separators "=,". That call will return "maxDump" as the token. The code assumes, that "maxDump=<number>" is being returned.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      $ JAVA_HOME=/usr/jdk1.5.0
      $ LD_LIBRARY_PATH=$JAVA_HOME/demo/jvmti/heapTracker/lib
      $ export LD_LIBRARY_PATH
      $ $JAVA_HOME/bin/java -server -Xbootclasspath/a:$JAVA_HOME/demo/jvmti/heapTracker/heapTracker.jar -agentlib:heapTracker=maxDump=6 -version
      ERROR: Unknown option: maxDump


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      With Patch applied:

      $ JAVA_HOME=/usr/jdk1.5.0
      $ LD_LIBRARY_PATH=$PATCHED_LIB_PATH
      $ export LD_LIBRARY_PATH
      $ /usr/local/jdk1.5.0/bin/java -server -Xbootclasspath/a:/usr/local/jdk1.5.0/demo/jvmti/heapTracker/heapTracker.jar -agentlib:heapTracker=maxDump=6 -version
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Server VM (build 1.5.0_01-b08, mixed mode)
      Dumping heap trace information
       1: 275200 bytes 3005 objects 2624 live before VM_INIT stack=<empty>
       2: 2504 bytes 43 objects 43 live unknown stack=<empty>
       3: 1072 bytes 35 objects 34 live before VM_START stack=<empty>
       4: 480 bytes 5 objects 5 live stack=(Ljava/lang/Object;.<init>@1,Ljava/lang/Thread;.<init>@1) nframes=2
       5: 240 bytes 5 objects 5 live stack=(Ljava/lang/String;.toCharArray@7,Ljava/lang/Thread;.init@91,Ljava/lang/Thread;.<init>@45) nframes=3
       6: 40 bytes 5 objects 5 live stack=(Ljava/lang/Object;.<init>@1,Ljava/lang/Thread;.<init>@34) nframes=2

      ACTUAL -
      ERROR: Unknown option: maxDump

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      ERROR: Unknown option: maxDump

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Not needed
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
        Patch $JAVA_HOME/demo/jvmti/heapTracker/src/heapTracker.c as follows:

      $ diff -c heapTracker.c.orig heapTracker.c
      *** heapTracker.c.orig Mon Dec 6 23:38:18 2004
      --- heapTracker.c Fri Jan 28 10:43:35 2005
      ***************
      *** 903,910 ****
                  stdout_message("\t maxDump=n\t\t\t How many TraceInfo's to dump\n");
                  stdout_message("\n");
                  exit(0);
      ! } else if ( strncmp(token,"maxDump=",8)==0 ) {
      ! gdata->maxDump = atoi(token+8);
              } else if ( token[0]!=0 ) {
                  /* We got a non-empty token and we don't know what it is. */
                  fatal_error("ERROR: Unknown option: %s\n", token);
      --- 903,919 ----
                  stdout_message("\t maxDump=n\t\t\t How many TraceInfo's to dump\n");
                  stdout_message("\n");
                  exit(0);
      ! } else if ( strcmp(token,"maxDump")==0 ) {
      ! char number[MAX_TOKEN_LENGTH];
      !
      ! /* Get the numeric option */
      ! next = get_token(next, ",=", number, (int)sizeof(number));
      ! /* Check for token scan error */
      ! if ( next==NULL ) {
      ! fatal_error("ERROR: maxDump=n option error\n");
      ! }
      ! /* Save numeric value */
      ! gdata->maxDump = atoi(number);
              } else if ( token[0]!=0 ) {
                  /* We got a non-empty token and we don't know what it is. */
                  fatal_error("ERROR: Unknown option: %s\n", token);

      That working code was taken from
      $JAVA_HOME/demo/jvmti/mtrace/src/mtrace.c
      ###@###.### 2005-05-09 10:28:45 GMT

            ohair Kelly Ohair (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: