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

vm crashes in native method on linux

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.3.0
    • hotspot
    • generic
    • generic

      [moved here from "multi-bug" 4352424]

      Name: yyT116575 Date: 11/27/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
      Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)


      My work is related on ping, traceroute, and nmap function so I implemented all
      necessary codes in C and displayed output on screen by using swing component.
      In the first step, I tried to just display the result from java part
      interactively by using CallVoidMethod() and calling System.out.println().
      Everything would be fine for all functions.

      Next step, I changed callback method in java part to just call another method,
      append(), of JTextArea. The result was VM has been crashed when calling. So I
      tried to call the same method directly in native part, C, it seemed work fine
      again for ping and nmap only. This solution doesn't work for traceroute.

      I also try another way. Traceroute may crash themself, I cut them off from
      native code, I means all of them. But I still got the same result. To do next,
      I add printf() between every line in C code and java code also to trace where
      the problem is. Then I found the problem. The program always crashed while
      executing "(*jenv)->CallVoidMethod(jenv,cls,mid,jstr);" because I saw all "in
      callback n" where n is 1 until 9 but I never saw 10!

      I really need to know the solution for this problem to continue my work.

      /* java code */
      package trace;
      import javax.swing.*;

      public class NativeTrace {
              public native String[] doTrace(String host,
                      int size,int ttl,int wait,int resolve,JTextArea text);

              public void trace(String host,
                      int size,int ttl,int wait,boolean resolve,JTextArea text) {
                      int res = 0;
                      if (resolve) res = 1;
                      String result[] = doTrace(host,size,ttl,wait,res,text);
              }

              static {
                      System.loadLibrary("trace");
              }
      }


      /* snippet C code */
      static JNIEnv *jenv;
      static jobject jobj;
      static jobject jtext;

      void callback() {
              if (!jtext) return;
              printf("in callback 6\n");
              cls = (*jenv)->GetObjectClass(jenv,jtext);
              if (cls == 0) {
                      fprintf(stderr,"Can't find class javax.swing.JTextArea\n");
                      exit(1);
              }

              printf("in callback 7\n");
              mid = (*jenv)->GetMethodID(jenv,cls,"append","(Ljava/lang/String;)V");
              if (mid == 0) {
                      fprintf(stderr,"Can't find method append\n");
                      exit(1);
              }

              printf("in callback 8\n");
              jstr = (*jenv)->NewStringUTF(jenv,buf);
              printf("in callback 9 %d %d %d %d\n",
                              (int)jenv,(int)cls,(int)mid,(int)jstr);
              (*jenv)->CallVoidMethod(jenv,cls,mid,jstr);
              printf("in callback 10\n");
      }

      JNIEXPORT jobjectArray JNICALL Java_trace_NativeTrace_doTrace
        (JNIEnv * env, jobject obj, jstring jhost,
         jint size, jint ttl, jint wait, jint resolve, jobject text)
      {
              callback("158.108.33.65",1,1.0,0,3);
              return NULL;
      }

      #
      # HotSpot Virtual Machine Error, Unexpected Signal 11
      # Please report this error at
      # http://java.sun.com/cgi-bin/bugreport.cgi
      #
      # Error ID: 4F533F4C494E55580E43505005BC
      #
      # Problematic Thread: prio=1 tid=0x810dc50 nid=0x714f runnable
      #
      (Review ID: 112817)

            jcoomes John Coomes (Inactive)
            jcoomes John Coomes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: