Calling the same function twice cause error JNI and MASM
up vote
-1
down vote
favorite
I've function that converts image applying some filter. When i trigger it (via .dll) and JNI interface in java for the first time I recive correct result. But when i want to call it second time, I get an access violation exception. I may add that i don't use any constant in this assembly program. What can cause such issues? I've debugged by this program and it seems it is getting wrong value
mov rcx, env
mov rdx, image
mov r8, count
mov rax, functionTable
call QWORD PTR[rax + 173 * 8]
mov rdx, rax
these call return to me 0 in rax. In the first call it returns proper value
My JNI function
public native void function(int image, int width, int height);
I may add that I've exacly the same code but written in .cpp also called by java and there everything works fine. MASM is written for Windows x64 ABI
assembly jni x86-64 masm masm64
add a comment |
up vote
-1
down vote
favorite
I've function that converts image applying some filter. When i trigger it (via .dll) and JNI interface in java for the first time I recive correct result. But when i want to call it second time, I get an access violation exception. I may add that i don't use any constant in this assembly program. What can cause such issues? I've debugged by this program and it seems it is getting wrong value
mov rcx, env
mov rdx, image
mov r8, count
mov rax, functionTable
call QWORD PTR[rax + 173 * 8]
mov rdx, rax
these call return to me 0 in rax. In the first call it returns proper value
My JNI function
public native void function(int image, int width, int height);
I may add that I've exacly the same code but written in .cpp also called by java and there everything works fine. MASM is written for Windows x64 ABI
assembly jni x86-64 masm masm64
It could be any number of things:count
could be out of bounds; you might have a pending Java exception from a previous JNI call; you might have deleted a necessary Java reference, etc. You'll have to provide more information.
– Michael
Nov 11 at 16:32
@Michael I'm invoking the same code twice with exacly the same parameters, but as I mention with different behaviour. Every varibale is initialized by passed parameters by java so I highly doubt it is connected with this. You have pointed that it might be caused by previous exception from JNI. After performingret
in the first function call i'm getting some exceptions but overall the program returns from MASM to java and correctly display result. May it be connected? I assumed that after one call everything (especially exceptions are being cleared)
– Michal
Nov 11 at 22:33
I may also add that every of exceptions i mentioned (afterret
) and during second call of assembler function are thrown inException thrown at 0x0000000... (jvm.dll) in java.exe:
-> jvm.dll
– Michal
Nov 11 at 22:39
1
Calling the same JNI function twice is not a problem. So obviously the problem is something else that you're doing (or not doing). But we don't know what that might be, because we only have a short code fragment that in and of itself is not a problem. So e.g. where is your call toReleaseIntArrayElements
? Where is all your error handling (checking for exceptions and bad return values)?
– Michael
Nov 12 at 8:14
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I've function that converts image applying some filter. When i trigger it (via .dll) and JNI interface in java for the first time I recive correct result. But when i want to call it second time, I get an access violation exception. I may add that i don't use any constant in this assembly program. What can cause such issues? I've debugged by this program and it seems it is getting wrong value
mov rcx, env
mov rdx, image
mov r8, count
mov rax, functionTable
call QWORD PTR[rax + 173 * 8]
mov rdx, rax
these call return to me 0 in rax. In the first call it returns proper value
My JNI function
public native void function(int image, int width, int height);
I may add that I've exacly the same code but written in .cpp also called by java and there everything works fine. MASM is written for Windows x64 ABI
assembly jni x86-64 masm masm64
I've function that converts image applying some filter. When i trigger it (via .dll) and JNI interface in java for the first time I recive correct result. But when i want to call it second time, I get an access violation exception. I may add that i don't use any constant in this assembly program. What can cause such issues? I've debugged by this program and it seems it is getting wrong value
mov rcx, env
mov rdx, image
mov r8, count
mov rax, functionTable
call QWORD PTR[rax + 173 * 8]
mov rdx, rax
these call return to me 0 in rax. In the first call it returns proper value
My JNI function
public native void function(int image, int width, int height);
I may add that I've exacly the same code but written in .cpp also called by java and there everything works fine. MASM is written for Windows x64 ABI
assembly jni x86-64 masm masm64
assembly jni x86-64 masm masm64
edited Nov 12 at 8:14
Michael
42.2k84292
42.2k84292
asked Nov 11 at 15:26
Michal
13
13
It could be any number of things:count
could be out of bounds; you might have a pending Java exception from a previous JNI call; you might have deleted a necessary Java reference, etc. You'll have to provide more information.
– Michael
Nov 11 at 16:32
@Michael I'm invoking the same code twice with exacly the same parameters, but as I mention with different behaviour. Every varibale is initialized by passed parameters by java so I highly doubt it is connected with this. You have pointed that it might be caused by previous exception from JNI. After performingret
in the first function call i'm getting some exceptions but overall the program returns from MASM to java and correctly display result. May it be connected? I assumed that after one call everything (especially exceptions are being cleared)
– Michal
Nov 11 at 22:33
I may also add that every of exceptions i mentioned (afterret
) and during second call of assembler function are thrown inException thrown at 0x0000000... (jvm.dll) in java.exe:
-> jvm.dll
– Michal
Nov 11 at 22:39
1
Calling the same JNI function twice is not a problem. So obviously the problem is something else that you're doing (or not doing). But we don't know what that might be, because we only have a short code fragment that in and of itself is not a problem. So e.g. where is your call toReleaseIntArrayElements
? Where is all your error handling (checking for exceptions and bad return values)?
– Michael
Nov 12 at 8:14
add a comment |
It could be any number of things:count
could be out of bounds; you might have a pending Java exception from a previous JNI call; you might have deleted a necessary Java reference, etc. You'll have to provide more information.
– Michael
Nov 11 at 16:32
@Michael I'm invoking the same code twice with exacly the same parameters, but as I mention with different behaviour. Every varibale is initialized by passed parameters by java so I highly doubt it is connected with this. You have pointed that it might be caused by previous exception from JNI. After performingret
in the first function call i'm getting some exceptions but overall the program returns from MASM to java and correctly display result. May it be connected? I assumed that after one call everything (especially exceptions are being cleared)
– Michal
Nov 11 at 22:33
I may also add that every of exceptions i mentioned (afterret
) and during second call of assembler function are thrown inException thrown at 0x0000000... (jvm.dll) in java.exe:
-> jvm.dll
– Michal
Nov 11 at 22:39
1
Calling the same JNI function twice is not a problem. So obviously the problem is something else that you're doing (or not doing). But we don't know what that might be, because we only have a short code fragment that in and of itself is not a problem. So e.g. where is your call toReleaseIntArrayElements
? Where is all your error handling (checking for exceptions and bad return values)?
– Michael
Nov 12 at 8:14
It could be any number of things:
count
could be out of bounds; you might have a pending Java exception from a previous JNI call; you might have deleted a necessary Java reference, etc. You'll have to provide more information.– Michael
Nov 11 at 16:32
It could be any number of things:
count
could be out of bounds; you might have a pending Java exception from a previous JNI call; you might have deleted a necessary Java reference, etc. You'll have to provide more information.– Michael
Nov 11 at 16:32
@Michael I'm invoking the same code twice with exacly the same parameters, but as I mention with different behaviour. Every varibale is initialized by passed parameters by java so I highly doubt it is connected with this. You have pointed that it might be caused by previous exception from JNI. After performing
ret
in the first function call i'm getting some exceptions but overall the program returns from MASM to java and correctly display result. May it be connected? I assumed that after one call everything (especially exceptions are being cleared)– Michal
Nov 11 at 22:33
@Michael I'm invoking the same code twice with exacly the same parameters, but as I mention with different behaviour. Every varibale is initialized by passed parameters by java so I highly doubt it is connected with this. You have pointed that it might be caused by previous exception from JNI. After performing
ret
in the first function call i'm getting some exceptions but overall the program returns from MASM to java and correctly display result. May it be connected? I assumed that after one call everything (especially exceptions are being cleared)– Michal
Nov 11 at 22:33
I may also add that every of exceptions i mentioned (after
ret
) and during second call of assembler function are thrown in Exception thrown at 0x0000000... (jvm.dll) in java.exe:
-> jvm.dll– Michal
Nov 11 at 22:39
I may also add that every of exceptions i mentioned (after
ret
) and during second call of assembler function are thrown in Exception thrown at 0x0000000... (jvm.dll) in java.exe:
-> jvm.dll– Michal
Nov 11 at 22:39
1
1
Calling the same JNI function twice is not a problem. So obviously the problem is something else that you're doing (or not doing). But we don't know what that might be, because we only have a short code fragment that in and of itself is not a problem. So e.g. where is your call to
ReleaseIntArrayElements
? Where is all your error handling (checking for exceptions and bad return values)?– Michael
Nov 12 at 8:14
Calling the same JNI function twice is not a problem. So obviously the problem is something else that you're doing (or not doing). But we don't know what that might be, because we only have a short code fragment that in and of itself is not a problem. So e.g. where is your call to
ReleaseIntArrayElements
? Where is all your error handling (checking for exceptions and bad return values)?– Michael
Nov 12 at 8:14
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250210%2fcalling-the-same-function-twice-cause-error-jni-and-masm%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It could be any number of things:
count
could be out of bounds; you might have a pending Java exception from a previous JNI call; you might have deleted a necessary Java reference, etc. You'll have to provide more information.– Michael
Nov 11 at 16:32
@Michael I'm invoking the same code twice with exacly the same parameters, but as I mention with different behaviour. Every varibale is initialized by passed parameters by java so I highly doubt it is connected with this. You have pointed that it might be caused by previous exception from JNI. After performing
ret
in the first function call i'm getting some exceptions but overall the program returns from MASM to java and correctly display result. May it be connected? I assumed that after one call everything (especially exceptions are being cleared)– Michal
Nov 11 at 22:33
I may also add that every of exceptions i mentioned (after
ret
) and during second call of assembler function are thrown inException thrown at 0x0000000... (jvm.dll) in java.exe:
-> jvm.dll– Michal
Nov 11 at 22:39
1
Calling the same JNI function twice is not a problem. So obviously the problem is something else that you're doing (or not doing). But we don't know what that might be, because we only have a short code fragment that in and of itself is not a problem. So e.g. where is your call to
ReleaseIntArrayElements
? Where is all your error handling (checking for exceptions and bad return values)?– Michael
Nov 12 at 8:14