目的:給傳入的物件屬性賦予新值,
jni與native函式:
public native int authAccount(String account, String password, String check_new, String check_old, int err_code, int auth_result, Result result);
JNIEXPORT jint JNICALL
Java_com_example_sslvpn_1android_1sdk_GmSSL_authAccount(JNIEnv *env, jobject thiz, jstring account,
jstring password, jstring check_new,
jstring check_old, jint err_code,
jint auth_result, jobject result) {
// TODO: implement authAccount()
char *accountChar = (*env)->GetStringUTFChars(env,account,NULL);
char *passwordChar = (*env)->GetStringUTFChars(env,password,NULL);
// char *checkNewChar = (*env)->GetStringUTFChars(env,check_new,NULL);
// char *checkOldChar = (*env)->GetStringUTFChars(env,check_old,NULL);
jclass jclass1 = (*env)->GetObjectClass(env,result);
if(jclass1 == NULL){
return -1;
}
jfieldID jfieldId = (*env)->GetFieldID(env,jclass1,"res","Ljava/lang/String;");
jstring resValue = (*env)->GetObjectField(env,result,jfieldId);
char *resultChar = (*env)->GetStringUTFChars(env,resValue,NULL);
int res = sslvpn_auth_account(accountChar,passwordChar,NULL,NULL,&err_code,&auth_result,resultChar);
jstring resultString = (*env)->NewStringUTF(env,resultChar);
(*env)->SetObjectField(env,result,jfieldId,resultString);
(*env)->ReleaseStringUTFChars(env,account,accountChar);
(*env)->ReleaseStringUTFChars(env,password,passwordChar);
// (*env)->ReleaseStringUTFChars(env,check_new,checkNewChar);
// (*env)->ReleaseStringUTFChars(env,check_old,checkOldChar);
(*env)->ReleaseStringUTFChars(env,resValue,resultChar);
// (*env)->DeleteLocalRef(env,resultString);
// (*env)->DeleteLocalRef(env,jclass1);
return res;
}
報錯:
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7465530a0d544d
x0 0000007605a27140 x1 000000760616b914 x2 0000000000000040 x3 0000000080407202
x4 0000007605a20848 x5 000000760616ba80 x6 0000007609c50260 x7 0000007612766ef0
x8 0000000000000000 x9 2d7465530a0d544d x10 0000000000000001 x11 0000000000000000
x12 0000007606473030 x13 0000007606473098 x14 0000000000000012 x15 00000000000000ff
x16 00000076960fb260 x17 00000076960f82b0 x18 00000075a7b72000 x19 0000007605a27140
x20 000000760616b914 x21 0000007605ab3ca8 x22 0000000000000000 x23 000000760616c020
x24 000000760616c020 x25 000000760616bd50 x26 000000760616c020 x27 000000760646f020
x28 0000000000000000 x29 000000760616b900
sp 000000760616b8f0 lr 00000076960f81e0 pc 00000076960f8334
backtrace:
#00 pc 0000000000002334 /system/lib64/libbinderthreadstate.so (_ZNSt3__15dequeIN7android18IPCThreadStateBase9CallStateENS_9allocatorIS3_EEE12emplace_backIJRS3_EEES8_DpOT_+132) (BuildId: cee8adb14565f37dd2bf1ff1af525e63)
#01 pc 00000000000021dc /system/lib64/libbinderthreadstate.so (android::IPCThreadStateBase::pushCurrentState(android::IPCThreadStateBase::CallState)+36) (BuildId: cee8adb14565f37dd2bf1ff1af525e63)
#02 pc 00000000000641d4 /system/lib64/libbinder.so (android::IPCThreadState::executeCommand(int)+820) (BuildId: 9cdc521320b9aad87123c58011fc602e)
#03 pc 0000000000063dec /system/lib64/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+156) (BuildId: 9cdc521320b9aad87123c58011fc602e)
#04 pc 0000000000064674 /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+60) (BuildId: 9cdc521320b9aad87123c58011fc602e)
#05 pc 000000000008a910 /system/lib64/libbinder.so (android::PoolThread::threadLoop()+24) (BuildId: 9cdc521320b9aad87123c58011fc602e)
#06 pc 00000000000136d8 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+288) (BuildId: b033168dfe889b3bc8dd188a3d69a675)
#07 pc 00000000000e9fd4 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+140) (BuildId: 6eda35f292c7c747d85e4432cb3e561b)
#08 pc 00000000000ce1b0 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: 212095a5bb472f1fd33898cf4066bc50)
#09 pc 0000000000070ba8 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 212095a5bb472f1fd33898cf4066bc50)
uj5u.com熱心網友回復:
IPCThreadStateBase CallState allocatorI這里發生了踩記憶體,看看是不是記憶體分配出問題了
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/283469.html
標籤:Android
