HotSpot Virtual Machine Error

First, I' sorry that I don't write English well.

I have an error my JNI program with C program.

Error message same to bellow.

Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6d4483d7

Function name=(N/A)

Library=c:\jdk1.3\jre\bin\hotspot\jvm.dll

NOTE: We are unable to locate the function name symbol for the error

just occurred. Please refer to release documentation for possible

reason and solutions.

Current Java thread:

at JavaCipher.encryptFile(Native Method)

at JavaCipher.<init>(JavaCipher.java:32)

at CallSecureDocDll.main(CallSecureDocDll.java:34)

Dynamic libraries:

0x00400000 - 0x00405000 c:\jdk1.3\bin\java.exe

0x77F80000 - 0x77FFB000 C:\WINNT\System32\ntdll.dll

0x77D80000 - 0x77DDB000 C:\WINNT\system32\ADVAPI32.dll

0x77E50000 - 0x77F33000 C:\WINNT\system32\KERNEL32.DLL

0x77D10000 - 0x77D80000 C:\WINNT\system32\RPCRT4.DLL

0x78000000 - 0x78046000 C:\WINNT\system32\MSVCRT.dll

0x6D420000 - 0x6D4F0000 c:\jdk1.3\jre\bin\hotspot\jvm.dll

0x77DE0000 - 0x77E44000 C:\WINNT\system32\USER32.dll

0x77F40000 - 0x77F7C000 C:\WINNT\system32\GDI32.DLL

0x77520000 - 0x77550000 C:\WINNT\System32\WINMM.dll

0x75DF0000 - 0x75E0A000 C:\WINNT\System32\IMM32.DLL

0x6D220000 - 0x6D227000 c:\jdk1.3\jre\bin\hpi.dll

0x6D3B0000 - 0x6D3BD000 c:\jdk1.3\jre\bin\verify.dll

0x6D250000 - 0x6D266000 c:\jdk1.3\jre\bin\java.dll

0x6D3C0000 - 0x6D3CD000 c:\jdk1.3\jre\bin\zip.dll

0x10000000 - 0x1006C000 D:\SecureDoc\Server\class\SecureDoc\libcrypt.dll

0x778F0000 - 0x77913000 C:\WINNT\system32\imagehlp.dll

0x72920000 - 0x7294D000 C:\WINNT\system32\DBGHELP.dll

0x68BD0000 - 0x68BDB000 C:\WINNT\System32\PSAPI.DLL

Local Time = Fri Apr 12 17:03:36 2002

Elapsed Time = 0

#

# HotSpot Virtual Machine Error : EXCEPTION_ACCESS_VIOLATION

# Error ID : 4F530E43505002C4

# Please report this error at

# http://java.sun.com/cgi-bin/bugreport.cgi

#

# Java VM: Java HotSpot(TM) Client VM (1.3.1_02-b02 mixed mode)

#

and Java Source same to bellow.

// native method declare

native void cipher_init();

native int encryptFile( DocInfo info, int algo, int mode );

native int decryptFile( DocInfo info );

// load library

static {

System.loadLibrary("libcrypt");

}

// call encrypt method

public JavaCipher(String srv_no, String user_id, String pc_no, String make_date,

String user_name, String expire_date, String orign_doc_name, String orign_type,

String sdf_doc_name, char support_offline, char assign_access_level, byte encrypt_key[])

{

DocInfo dinfo = new DocInfo(srv_no, user_id, pc_no, make_date, user_name, expire_date,

orign_doc_name, orign_type, sdf_doc_name, support_offline, assign_access_level,

encrypt_key);

cipher_init();

int ret = encryptFile(dinfo, CIPHER_ALGO_3DES, CIPHER_MODE_CBC);

}

and C source same to bellow

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include "config.h"

#if (PLATFORM == PLATFORM_UNIX)

#include <unistd.h>

#endif

#include <sys/types.h>

#include <sys/stat.h>

#include "types.h"

#include "cipher.h"

#include "encode.h"

#ifdef JDK

#include "jni.h"

#include "JavaCipher.h"

#endif

#ifdef JDK

JNIEXPORT void JNICALL Java_JavaCipher_cipher_1init (JNIEnv *env, jobject obj)

{

cipher_init();

}

static void JavaChar2C(JNIEnv *env, jclass cls, jobject obj, char *field, char *dst)

{

jfieldID fid;

jchar j_char;

fid= (*env)->GetFieldID(env, cls, field, "C");

j_char = (*env)->GetCharField(env, obj, fid);

*dst= (char)j_char;

}

static void JavaString2C(JNIEnv *env, jclass cls, jobject obj, char *field, char *dst)

{

jfieldID fid;

jstring j_str;

const char *c_str;

fid= (*env)->GetFieldID(env, cls, field, "Ljava/lang/String;");

j_str = (*env)->GetObjectField(env, obj, fid);

c_str = (*env)->GetStringUTFChars(env, j_str, 0);

strcpy(dst, c_str);

(*env)->ReleaseStringUTFChars(env, j_str, c_str);

}

static void JavaKey2C(JNIEnv *env, jclass cls, jobject obj, char *field, char *dst)

{

int i;

jfieldID fid;

jbyteArray j_array;

jbyte *j_byte;

fid= (*env)->GetFieldID(env, cls, field, "[B");

j_array = (*env)->GetObjectField(env, obj, fid);

j_byte = (*env)->GetByteArrayElements(env, j_array, 0);

for(i=0; i < KEY_LEN; i++){

dst = (char) j_byte;

}

(*env)->ReleaseByteArrayElements(env, j_array, j_byte, 0);

}

JNIEXPORT jint JNICALL Java_JavaCipher_encryptFile

(JNIEnv *env, jobject obj, jobject j_info, jint algo, jint mode)

{

struct docinfo_t info;

jclass cls = (*env)->GetObjectClass(env, j_info);

JavaString2C(env, cls, j_info, "srv_no", info.srv_no);

JavaString2C(env, cls, j_info, "user_id", info.user_id);

JavaString2C(env, cls, j_info, "pc_no", info.pc_no);

JavaString2C(env, cls, j_info, "make_date", info.make_date);

JavaString2C(env, cls, j_info, "user_name", info.user_name);

JavaString2C(env, cls, j_info, "expire_date", info.expire_date);

JavaString2C(env, cls, j_info, "orign_doc_name", info.orign_doc_name);

JavaString2C(env, cls, j_info, "orign_doc_type", info.orign_doc_type);

JavaString2C(env, cls, j_info, "sdf_doc_name", info.sdf_doc_name);

JavaChar2C(env, cls, j_info, "support_offline", &info.support_offline);

JavaChar2C(env, cls, j_info, "assign_access_level", &info.assign_access_level);

JavaKey2C(env, cls, j_info, "encrypt_key", info.encrypt_key);

return encryptFile(&info, algo, mode);

}

/*************************************************************************/

static void C2JavaString(JNIEnv *env, jclass cls, jobject obj, char *field, char *src)

{

jfieldID fid;

jstring j_str = (*env)->NewStringUTF(env, src);

fid= (*env)->GetFieldID(env, cls, field, "Ljava/lang/String;");

(*env)->SetObjectField(env, obj, fid, j_str);

}

static void C2JavaChar(JNIEnv *env, jclass cls, jobject obj, char *field, char *src)

{

jfieldID fid;

jchar j_char = (jchar)*src;

fid= (*env)->GetFieldID(env, cls, field, "C");

(*env)->SetCharField(env, obj, fid, j_char);

}

static void C2JavaKey(JNIEnv *env, jclass cls, jobject obj, char *field, char *src)

{

jfieldID fid;

jbyteArray j_array = (*env)->NewByteArray(env, KEY_LEN);

fid= (*env)->GetFieldID(env, cls, field, "[B");

(*env)->SetByteArrayRegion(env, j_array, 0, KEY_LEN, (jbyte *)src);

(*env)->SetObjectField(env, obj, fid, j_array);

}

JNIEXPORT jint JNICALL Java_JavaCipher_decryptFile

(JNIEnv *env, jobject obj, jobject j_info)

{

int ret;

struct docinfo_t info;

jclass cls = (*env)->GetObjectClass(env, j_info);

JavaChar2C(env, cls, j_info, "support_offline", &info.support_offline);

JavaString2C(env, cls, j_info, "sdf_doc_name", info.sdf_doc_name);

ret=decryptFile(&info);

C2JavaString(env, cls, j_info, "srv_no", info.srv_no);

C2JavaString(env, cls, j_info, "user_id", info.user_id);

C2JavaString(env, cls, j_info, "pc_no", info.pc_no);

C2JavaString(env, cls, j_info, "make_date", info.make_date);

C2JavaString(env, cls, j_info, "user_name", info.user_name);

C2JavaString(env, cls, j_info, "expire_date", info.expire_date);

C2JavaString(env, cls, j_info, "orign_doc_name", info.orign_doc_name);

C2JavaString(env, cls, j_info, "orign_doc_type", info.orign_doc_type);

C2JavaChar(env, cls, j_info, "assign_access_level", &info.assign_access_level);

C2JavaKey(env, cls, j_info, "encrypt_key", info.encrypt_key);

return ret;

}

#endif

In C source, every native function call anthor C function.

[Example : Java_JavaCipher_cipher_1init() function call cipher_init() in anthor C source]

Please help me why this error was occured!

[8559 byte] By [lkh1976] at [2007-9-27 2:53:28]
# 1

These kinds of problems are typically due to errors in the native implementation. You haven't said what your development tools are, but since you are using a dll library, I will ASSUME that you have VisualC++ available. If that is the case, you can open your dll as the current workspace/project, set breakpoints in the native code, then set up your executeable to be java.exe. (You will have to figure out how to supply the appropriate command-line arguments.) This procedure will allow you to single-step the native code and examine variables.

bschauwe at 2007-7-4 23:18:49 > top of Java-index,Java HotSpot Virtual Machine,Specifications...