Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added env()->ExceptionClear() everywhere before throwing NameResolutionException #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hacker-cb
Copy link

@hacker-cb hacker-cb commented Dec 1, 2023

Uncleared exceptions cause SegFault on Android.

Android developer docs:You must not call most JNI functions while an exception is pending.

@@ -733,8 +743,10 @@ namespace jni
if (sig != nullptr)
return getStaticMethod(std::string(nameAndSignature, sig - nameAndSignature).c_str(), sig);

if (id == nullptr)
if (id == nullptr) {
env()->ExceptionClear();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ever possible to get in here when there is no env set yet?

@@ -709,8 +715,10 @@ namespace jni
if (sig != nullptr)
return getMethod(std::string(nameAndSignature, sig - nameAndSignature).c_str(), sig);

if (id == nullptr)
if (id == nullptr) {
env()->ExceptionClear();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - is it possible to get in without setting env?

@rpavlik
Copy link
Collaborator

rpavlik commented May 17, 2024

I wonder if there is a way to add a test for this. I guess we would have to throw a JNI exception that wouldn't be handled by jnipp?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants