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

Virtual Machine Error, Unexpected Signal 11 while using JNI

XMLWordPrintable

    • fcs
    • sparc
    • solaris_2.5.1
    • Not verified



      Name: dkC59003 Date: 04/28/99


      The tests nsk/coverage/jni/jni001 and jni002 crashes HotSpot for sparc
      1.0fcs-B build:

      $ runc.ksh
      cc: SC4.0 18 Oct 1995 C 4.0
      usage: cc [ options] files. Use 'cc -flags' for details
      #
      # HotSpot Virtual Machine Error, Unexpected Signal 11
      #
      signal fault in critical section
      signal number: 11, signal code: 1, fault address: 0x4, pc: 0xef4436b0, sp: 0xff0f8
      ABORT: core dump

      The same thing works fine on winNT with VC++ 5.0 and fcs-E build.
      Script to run the test and slightly simplified version of the test follow:

      ----------------------------------------------------------- runc.ksh
      #!/bin/ksh
      HS=/export/home/hotspot/jdk1.2

      export CLASSPATH=.
      export LD_LIBRARY_PATH=$HS/jre/lib/sparc/hotspot

      cc -V
      cc -KPIC -I$HS/include -I$HS/include/solaris -L$HS/jre/lib/sparc/classic -L$HS/jre/lib/sparc/native_threads -ljvm -lthread -o jni001.exe jni001.c

      if [ $? = 0 ]; then
          jni001.exe
          echo $?
      fi
      ----------------------------------------------------------- jni001.c
      #include <thread.h>
      #include <string.h>
      #include "jni.h"

      thread_t tid[1];
      jint attachRes;
      jint detachRes;
      jint threadStatus;
      JavaVM *vm;

      void* trialThread( void *arg ) {
          jint res;
          jclass cls;
          jmethodID mid;
          jobject exc;
          JNIEnv *env;

          threadStatus = 0;
          env = (void *) 0xfafa;

          res = (*vm) -> GetEnv(vm, (void **) &env, JNI_VERSION_1_2);
          if ( res != JNI_EDETACHED || env != NULL ) {
              threadStatus = 2;
              fprintf(stderr, "Error: wrong result of GetEnv when the current thread is "
                              "not attached to the VM.\n");
          }

          attachRes = (*vm) -> AttachCurrentThread( vm, (void **) &env, (void *) 0 );
          if ( attachRes != 0 )
              fprintf(stderr, "Error: attach status = %d\n", attachRes );
          
          detachRes = (*vm) -> DetachCurrentThread( vm );
          if ( detachRes != 0 )
              fprintf(stderr, "Error: detach status = %d\n", detachRes );
          return NULL;
      }

      int fail( char* msg ) {
          printf( "Error: %s", msg );
          return 2; /*STATUS_FAILED*/
      }

      main ( int argc, char *argv[] ) {
          JavaVMInitArgs vm_args;
          JavaVMOption options[3];
          jint res;
          JNIEnv *env;
          jclass cls;
          jmethodID mid;
          jobject exc;
          char *cpoptionName;
          char *cpoption;
          const char *classpath;

          classpath = (char*) getenv( "CLASSPATH" );
          if( classpath == NULL )
              return fail("environment variable CLASSPATH is not set.\n");

          vm_args.version = JNI_VERSION_1_2;
          cpoptionName = "-Djava.class.path="; /* user classes option */
          cpoption = (char*) malloc((size_t) strlen(cpoptionName) + strlen(classpath) + 1);
          if ( cpoption == NULL )
              return fail("could not malloc array for classpath option.\n");
          cpoption = strcat(cpoption, cpoptionName);
          cpoption = strcat(cpoption, classpath);
          options[0].optionString = cpoption;
          vm_args.nOptions = 1;
          vm_args.options = options;
          vm_args.ignoreUnrecognized = JNI_TRUE;

          res = JNI_CreateJavaVM( &vm, (void **) &env, &vm_args );
          if ( res != 0 )
              return fail("could not create Java VM. Maybe the reason is "
                          "CLASSPATH doesn't point to java.lang.Thread class.\n");

          res = thr_create( NULL, 0, trialThread, (void *) 0, 0, tid );
          if ( res != 0 )
              return fail("could not create Solaris thread.\n");
          sleep(5);

          res = (*vm) -> AttachCurrentThread( vm, (void **) &env, (void *) 0 );
          if ( res != 0 )
              return fail( "Attach status was not 0.\n" );
          
          res = (*vm) -> DetachCurrentThread( vm );
          if ( res != 0 )
              return fail( "Detach status was not 0.\n" );

          if ((attachRes != 0) || (threadStatus != 0) || (detachRes != 0))
              return fail("Invalid test result.\n");

          free(cpoption);
          return 0 /*STATUS_PASSED*/;
      }

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

            jrose John Rose
            dkhukhrosunw Dmitry Khukhro (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: