Hi,

I have a problem under Linux loading the JVM since before I set a Handler to 
catch SIGSEGV signals. It seems that this causes some troubles when the JVM 
is loaded. This seems due to threads in Java. I saw several post from 
yourself about this topic.

I include my C test file (called x.c) and the command-line 
to compile it is:

gcc -o x /usr/java/jdk1.3/jre/lib/i386/client/libjvm.so x.c 
-I/usr/java/jdk1.3/include -I/usr/java/jdk1.3/include/linux -g -Wall

(assuming the JDK is installed in /usr/java/jdk1.3)

Here is the C file

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <jni.h>

JNIEnv *env;
JavaVM *vm;
jclass cls;

void
Load_JVM(void)
{
  JavaVMOption options[2];
  JavaVMInitArgs vm_args;

  options[0].optionString = "-Djava.class.path=."; /* user classes */

  vm_args.version = JNI_VERSION_1_2;
  vm_args.options = options;
  vm_args.nOptions = 1;
  vm_args.ignoreUnrecognized = 1;
    
  printf("READY TO LOAD THE JVM\n");
  if (JNI_CreateJavaVM(&vm, (void **)&env, (void *)&vm_args) < 0)
    {
      fprintf(stderr, "cannot load the JVM\n");
      exit(1);
    }

  printf("JVM LOADED\n");
}


void
SIGSEGV_Handler(void)

{
 fprintf(stderr, "Received SIGSEGV\n");
 exit(2);
}


int
main(int argc, char *argv[])
{
  signal(SIGSEGV, (void (*)()) SIGSEGV_Handler);
  Load_JVM();
  return 0;
}

It simply installs a handler for SIGSEGV and then loads the JVM. If you 
comment the line signal(SIGSEGV, (void (*)()) SIGSEGV_Handler) in the main(), 
this works properly but with the handler this crashes with:

READY TO LOAD THE JVM
#
# HotSpot Virtual Machine Error, Internal Error
# Please report this error at
# http://java.sun.com/cgi-bin/bugreport.cgi
#
# Error ID: 4F533F4C494E55580E4350500570
#
# Problematic Thread: Received SIGSEGV

Another strange problem occurs if you replace this line by
  system("uname -a");

after executing system() the JVM loading is blocked (in a sigsuspend I think).

Could you help me on this please ?

-- 
===============================================
                 Daniel Diaz
University of Paris 1      INRIA Rocquencourt
75013 Paris FRANCE      78153 Le Chesnay FRANCE
        web: http://pauillac.inria.fr/~diaz
        email: [EMAIL PROTECTED]
===============================================



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to