android - JNI CallVoidMethod leads to Fatal signal 6 and invalid indirect reference -
i'm trying send sms within android-ndk. when try call sendtextmessage
method in smsmanager
, app crashes error code of 6 (abort). furthermore, errormessage saying "invalid indirect reference 0xe7f03658 in decodeindirectref". think has object-refs, stated address isn't used objects using far can see.
the app crashes when last line executed. checked exceptions, none rising.
#ifndef null #define null ((void *) 0) #endif #include <string.h> #include <jni.h> #include <android/log.h> jniexport void jnicall java_tss_challenges_hybrid_app_sendsms(jnienv* env, jobject thiz) { jclass smsmanagerclz = (*env)->findclass(env, "android/telephony/smsmanager"); jmethodid getdefaultmethodid = (*env)->getstaticmethodid(env, smsmanagerclz, "getdefault", "()landroid/telephony/smsmanager;"); jobject smsmanagerobj = (*env)->callstaticobjectmethod(env, smsmanagerclz, getdefaultmethodid); jmethodid sendsmsmethodid = (*env)->getmethodid(env, smsmanagerclz, "sendtextmessage", "(ljava/lang/string;ljava/lang/string;ljava/lang/string;" "landroid/app/pendingintent;landroid/app/pendingintent;)v"); jstring number = (*env)->newstringutf(env, "1234"); jstring text = (*env)->newstringutf(env, "sms content"); jstring nullstring = (*env)->newstringutf(env, null); __android_log_print(android_log_verbose, "myapp", "%x,%x,%x,%x,%x,%x,%x,%x", number, text, nullstring,smsmanagerobj,sendsmsmethodid,env,smsmanagerclz,getdefaultmethodid); (*env)->callvoidmethod(env, smsmanagerobj, sendsmsmethodid, number, nullstring, text, null, null); }
logs:
05-11 14:17:00.718: d/dalvikvm(2376): trying load lib /data/app-lib/tss.chalenges.hybrid-1/libnativesmsmanager.so 0xb2d5b2d0 05-11 14:17:00.718: d/dalvikvm(2376): added shared lib /data/app-lib/tss.chalenges.hybrid-1/libnativesmsmanager.so 0xb2d5b2d0 05-11 14:17:00.718: d/dalvikvm(2376): no jni_onload found in /data/app-lib/tss.chalenges.hybrid-1/libnativesmsmanager.so 0xb2d5b2d0, skipping init 05-11 14:17:00.848: v/myapp(2376): c2900025,a0f00029,0,ba100021,b0be31c0,b82cff30,b680001d,b0be2f18 05-11 14:17:00.948: w/dalvikvm(2376): invalid indirect reference 0xe7f03658 in decodeindirectref 05-11 14:17:00.948: i/dalvikvm(2376): "main" prio=5 tid=1 runnable 05-11 14:17:00.948: i/dalvikvm(2376): | group="main" scount=0 dscount=0 obj=0xb2a94ca8 self=0xb82d3398 05-11 14:17:00.958: i/dalvikvm(2376): | systid=2376 nice=0 sched=0/0 cgrp=apps handle=-1225264812 05-11 14:17:00.958: i/dalvikvm(2376): | state=r schedstat=( 100000000 380000000 94 ) utm=6 stm=4 core=0 05-11 14:17:00.958: i/dalvikvm(2376): @ tss.challenges.hybrid.app.sendsms(native method) 05-11 14:17:00.958: i/dalvikvm(2376): @ tss.challenges.hybrid.app.oncreate(app.java:36) 05-11 14:17:00.958: i/dalvikvm(2376): @ android.app.activity.performcreate(activity.java:5231) 05-11 14:17:00.958: i/dalvikvm(2376): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) 05-11 14:17:00.958: i/dalvikvm(2376): @ android.app.activitythread.performlaunchactivity(activitythread.java:2159) 05-11 14:17:00.958: i/dalvikvm(2376): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2245) 05-11 14:17:00.958: i/dalvikvm(2376): @ android.app.activitythread.access$800(activitythread.java:135) 05-11 14:17:00.958: i/dalvikvm(2376): @ android.app.activitythread$h.handlemessage(activitythread.java:1196) 05-11 14:17:00.958: i/dalvikvm(2376): @ android.os.handler.dispatchmessage(handler.java:102) 05-11 14:17:00.958: i/dalvikvm(2376): @ android.os.looper.loop(looper.java:136) 05-11 14:17:00.958: i/dalvikvm(2376): @ android.app.activitythread.main(activitythread.java:5017) 05-11 14:17:00.958: i/dalvikvm(2376): @ java.lang.reflect.method.invokenative(native method) 05-11 14:17:00.958: i/dalvikvm(2376): @ java.lang.reflect.method.invoke(method.java:515) 05-11 14:17:00.958: i/dalvikvm(2376): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 05-11 14:17:00.958: i/dalvikvm(2376): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 05-11 14:17:00.958: i/dalvikvm(2376): @ dalvik.system.nativestart.main(native method) 05-11 14:17:00.998: e/dalvikvm(2376): vm aborting 05-11 14:17:01.018: a/libc(2376): fatal signal 6 (sigabrt) @ 0x00000948 (code=-6), thread 2376 (halenges.hybrid)
you no need pass null string, can directly pass null
in place of argument.
avoid this
jstring nullstring = (*env)->newstringutf(env, null);
try using null
or
jstring nullstring = (*env)->newstringutf(env, "");
Comments
Post a Comment