java - Updated DLL causes JNI to throw "Exception c0000005" -
This is my problem
I have a third DLL (for which I do not have a source) That I have to use to talk to JNI. The people who supply this DLL are not Java-houses. I have searched a bug in my DLL, so some C ++ is written, which used my DLL , Highlighted the bug and sent them to a fix. Eventually, I got the updated DLL back, my C ++ code (which worked fine) went and found out that the bug was actually fixed.
However, now when I use this new DLL inside my JNI code, the following exception is generated;
exception C0000005, LEEE34l6 access violation: Address 00000004 Try Native function reading memory on the heap data: 0,3f49c0,20201,801c6,65637845,6f697470,3063206e, 30,303,030 com.jniwrapper. FunctionExecutionException: on ComkjniwrapperkFunctionCallkcall (Sourcefile: 35) on com.jniwrapper: on C0000005 ComkjniwrapperkFunctionkinvokeCFunc (Native method) at com.jniwrapper.FunctionCall.a (127 sourcefile). Function.invoke (sourcefile: 188) com.tme.techdoc3.diagnostic.api.denso.DensoApiInvoker.invoke (DensoApiInvoker.java:78) on com.tme.techdoc3.diagnostic.api.denso.NewDensoApi.invoke (NewDensoApi. java: 106) E at I am actually providing my JNI code to use JNIWrapper and therefore I have written my own JNI code to govern my product to create a problem; But I still get this error, it assures me that the problem is in the third party DLL.
I'm getting this exception from the first function calling DLL (accidentally, this function did not have a bug in it ..).
Wherever we get from DLL, they have explicitly said that they will not support its use in JNI environment, even if they have given me some kind of release notes or The list of changes will not send between fixed and non-fixed DLLs.
Politically, there is nothing about this. Practically, I am limiting this supplier to DLL.
Can anyone think for any reason that this DLL is called from C ++, but when called in JNI? I am playing with JNI stack size (-Xss) and some other JVM parameters, but I have not hit the right settings or I am seeing the wrong things.
Any ideas are very appreciative
Many thanks
Edit: ... Adding to my own JNI code to see if a mistake can be seen
Edit 2: Corrected code copy-n-paste error
when I use my own JNI code, here's the implementation of .cpp file I'm using.
#include "stdafx .h" #include "windows.h" # "MyJniApi.h" # include "# Third Prti" #include to #pragma comment (lib, "Third Prti .lib "); Thirdparting * third party; JNIEXPORT jlong JNICALL Java_com_mycompany_jni_MyJniApi_connect (JNIEnv *, Job) {long connId = 0L; Third party = new third party (); Long retval = thirdparty-> gateconnection (& amp; connId); If (0 == retal) {return connId; } And {return Revail; }}
As you can see, it is very easy and I can not see any place there when my pointers get etc. I (Disclaimer: It is too much I have ++ Skills!)
c0000005 An "access violation" usually means that an indicator Usage has invalid memory address, it can only be a bad indicator value e.g.
I will look at two things:
-
You are going through some kind of arguments in particular in some way. I have not used JN directly, but I think a variable can be isolated in C ++ if it can be written instead of just reading it. Ensure that any buffers you are passing are allocated if DLL API expects them to be allocated in advance.
-
The lifetime of objects, make sure that the Java objects you are working with are not being collected for C ++ during calls.
Comments
Post a Comment