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

the jni function NewDirectByteBuffer() crashes JVM

XMLWordPrintable

    • sparc
    • solaris_8



      Name: viR10068 Date: 08/14/2001


      The simple test for jni function NewDirectByteBuffer() is failed
      on the jdk1.4.0-beta_refresh-b74 due to JVM crash.

      To reproduce:
      1. compile the ndbb00101m1.java
         Used: javac -d . ndbb00101m1.java
      2. compile the gdbc00101m1.c
         Used: cc -G -KPIC -o libjckjni.so -Iinclude ndbb00101m1.c
         In 'include' directory you should place 3 files (see attachments):
         % ls include
         jckjlong_md.h jckjni.h jckjni_md.h

      3. set environment variable LD_LIBRARY_PATH to working directory
      4. run ndbb00101m1
         Used: java -Xfuture javasoft.sqe.tests.vm.jni.ndbb001.ndbb00101m1.ndbb00101m1

      Execution log:
      % java -version
      java version "1.4.0-beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b74)
      Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b74, mixed mode)
      % java -Xfuture javasoft.sqe.tests.vm.jni.ndbb001.ndbb00101m1.ndbb00101m1
      Unexpected Signal : 11 occurred at PC=0xFE518C00
      Function=JVM_FillInStackTrace+0x1528
      Library=/export/ld54/java/dest/jdk1.4.0beta-b74/solsparc/jre/lib/sparc/client/libjvm.so

      Current Java thread:
              at sun.misc.Unsafe.getByte(Native Method)
              at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:179)
              at
      javasoft.sqe.tests.vm.jni.ndbb001.ndbb00101m1.ndbb00101m1.testChecks(ndbb00101m1.java:22)
              at
      javasoft.sqe.tests.vm.jni.ndbb001.ndbb00101m1.ndbb00101m1.run(ndbb00101m1.java:62)
              at
      javasoft.sqe.tests.vm.jni.ndbb001.ndbb00101m1.ndbb00101m1.main(ndbb00101m1.java:66)

      Dynamic libraries:
      0x10000 java
      0xff360000 /usr/lib/libthread.so.1
      0xff3a0000 /usr/lib/libdl.so.1
      0xff280000 /usr/lib/libc.so.1
      0xff270000 /usr/platform/SUNW,Ultra-1/lib/libc_psr.so.1
      0xfe400000
      /export/ld54/java/dest/jdk1.4.0beta-b74/solsparc/jre/lib/sparc/client/libjvm.so
      0xff210000 /usr/lib/libCrun.so.1
      0xff1f0000 /usr/lib/libsocket.so.1
      0xff100000 /usr/lib/libnsl.so.1
      0xff0d0000 /usr/lib/libm.so.1
      0xff240000 /usr/lib/libw.so.1
      0xff0b0000 /usr/lib/libmp.so.2
      0xff080000
      /export/ld54/java/dest/jdk1.4.0beta-b74/solsparc/jre/lib/sparc/native_threads/libhpi.so
      0xff050000
      /export/ld54/java/dest/jdk1.4.0beta-b74/solsparc/jre/lib/sparc/libverify.so
      0xff020000 /export/ld54/java/dest/jdk1.4.0beta-b74/solsparc/jre/lib/sparc/libjava.so
      0xfe7e0000 /export/ld54/java/dest/jdk1.4.0beta-b74/solsparc/jre/lib/sparc/libzip.so
      0xfe210000 /usr/lib/locale/ru_RU.KOI8-R/ru_RU.KOI8-R.so.2
      0xfe1a0000 /home/viv/tests/tmp/jni/libjckjni.so

      Local Time = Fri Aug 10 17:31:25 2001
      Elapsed Time = 2
      #
      # HotSpot Virtual Machine Error : 11
      # Error ID : 4F530E43505002D7 01
      # Please report this error at
      # http://java.sun.com/cgi-bin/bugreport.cgi
      #
      # Java VM: Java HotSpot(TM) Client VM (1.4.0-beta_refresh-b74 mixed mode)
      #
      # An error report file has been saved as hs_err_pid28447.log.
      # Please refer to the file for further information.
      #
      Abort
      %
      ---------------------------ndbb00101m1.java ---------------------------
      package javasoft.sqe.tests.vm.jni.ndbb001.ndbb00101m1;
      import java.io.PrintStream;
      import java.nio.*;

      public class ndbb00101m1 {

          private static boolean res = false;

          private static native ByteBuffer newDirectBuffer(byte[] data, long buf_len);

          public static int testChecks(PrintStream out) {

              try {
                  byte[] testData = new byte[] {3, 4, 5, 0, 2, 6, 7, 1};
                  ByteBuffer buf = newDirectBuffer(testData, testData.length);
                  for(int i=0; i<testData.length; i++) {
                      buf.get(i);
                  }
              } catch (Exception e) {
                  e.printStackTrace();
                  out.println("Unexpected exception: " + e);
                  res = true;
              }

              if(res)
                  return 2/*STATUS_FAILED*/;
              return 0/*STATUS_PASSED*/;
          }

          static String loadLibraryStatus = "";
          static {
              if(!loadLib("ndbb00101m1"))
                  loadLib("jckjni");
          }

          static boolean loadLib(String libName){
              try {
                  System.loadLibrary(libName);
                  loadLibraryStatus = null;
                  return true;
              } catch (SecurityException e) {
                  loadLibraryStatus += "loadLibrary(\"" + libName + "\") throws: " + e + "\n";
              } catch (UnsatisfiedLinkError e) {
                  loadLibraryStatus += "loadLibrary(\"" + libName + "\") throws: " + e + "\n";
              }
              return false;
          }

          public static int run(String argv[], PrintStream out) {

              if (loadLibraryStatus!=null) {
                  out.println("Library loading:\n" + loadLibraryStatus);
              }
              return testChecks(out);
          }

          public static void main(String argv[]) {
              System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
          }
      }
      ---------------------------ndbb00101m1.c ---------------------------
      #include <stdlib.h>
      #include <string.h>
      #include <stdio.h>
      #include "jckjni.h"

      #ifdef __cplusplus
      extern "C" {
      #endif

      #ifndef JNI_ENV_ARG

      #ifdef __cplusplus
      #define JNI_ENV_ARG(x, y) y
      #define JNI_ENV_PTR(x) x
      #else
      #define JNI_ENV_ARG(x,y) x, y
      #define JNI_ENV_PTR(x) (*x)
      #endif

      #endif


      static jbyte ndbb00101m1_buf[8];

      JNIEXPORT jobject JNICALL
      Java_javasoft_sqe_tests_vm_jni_ndbb001_ndbb00101m1_ndbb00101m1_newDirectBuffer
      (JNIEnv *env, jobject obj, jbyteArray arr, jlong buf_len) {

          jobject address;
          jbyte* testData;
          int i;

          address =
      JNI_ENV_PTR(env)->NewDirectByteBuffer(JNI_ENV_ARG(env,(void*)ndbb00101m1_buf), buf_len);
          return address;
      }

      #ifdef __cplusplus
      }
      #endif
      ---------------------------

      The new JCK test
      vm/jni/NewDirectByteBuffer/ndbb001/ndbb00101m1/ndbb00101m1.html
      is failed due to this bug.

      ======================================================================

            kbr Kenneth Russell (Inactive)
            vivsunw Viv Viv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: