简体   繁体   中英

For loop causes: VM aborting - Fatal signal 6 (SIGABRT) code=-6

I don't know why this error is thrown. Only when a loop is used does the app crash. I am importing an ArrayList < ArrayList < Point > > into the ndk. I can't open video files in ndk with opencv for videoprocessing, hence I am getting the positions with javacv on the java side (I am new to android in general and I could not find a more elegant method)

The outer array has a length of 10 (max 50) and inner has a varying length (200 - 500)

I initially thought maybe it is due memory limits in android. I believe now that it cannot be because I ran an empty loop iterating 10 times. It gives me the same error. I don't understand what this error means.

I am new to android. Can someone help me out? How should go about this? I am grateful for any and all suggestions. Thanks in advance!

CODE:

    // Class totd to get obj arraylist
    jclass totd = env -> FindClass ("java/util/ArrayList");

    //Methods in totd
    jmethodID totd_get = env-> GetMethodID (totd, "get", "(I)Ljava/lang/Object;");
    jmethodID totd_size = env-> GetMethodID (totd, "size", "()I");

    //Get length of ArrayList

jint totd_len = env-> CallIntMethod (totdat,totd_size);
//start loop for each frame process data:
jint i;
vector<vector<Point> > totalpnts;
for (i=0;i<=totd_len;i++){

    //Get postion data for current frame
    jobject fd = env-> CallObjectMethod (totdat,totd_get,i);
    jclass curd = env-> FindClass ("java/util/ArrayList");
    //Get methods of inner array
    jmethodID curd_get = env-> GetMethodID (curd, "get", "(I)Ljava/lang/Object;");
    jmethodID curd_size = env-> GetMethodID (curd, "size", "()I");
    //Get no. of objects found
    jint objcnt = env-> CallIntMethod (fd,curd_size);
    //Extract data from point
    jlong j = 0;
    vector<Point> framepnts;
    //for(j = 0; j <= objcnt ; j++){
        //Id objlist
        jobject ptxy = env-> CallObjectMethod (fd,curd_get,j);
        jclass pnt = env-> GetObjectClass(ptxy);
        jmethodID constr = env->GetMethodID(pnt, "<init>", "(II)V");
        jfieldID fix = env->GetFieldID(pnt, "x", "I");
        jfieldID fiy = env->GetFieldID(pnt, "y", "I");

        Point xy;
        xy.x = env-> GetIntField(ptxy,fix);
        xy.y = env-> GetIntField(ptxy,fiy);
        framepnts.push_back(xy);

    //}


    totalpnts.push_back(framepnts);


}

ERROR:

05-08 13:30:38.593: E/dalvikvm(17064): VM aborting
05-08 13:30:38.595: A/libc(17064): Fatal signal 6 (SIGABRT) at 0x000042a8 (code=-6), thread 17064 (st.trackerproto)

Im not from NDK/C++ world but I know that debugging in NDK world is a complicated task . From the java side you will always get Fatal signal N (SIGABRT) (no matter what happens on NDK layer) which means there some error happens in your C++ code. But you wont know what kind of error it was (however the N value could be different like 6 or 11) since its Java and it can't know why. You are thinking that the loop is an issue but you don't know for sure, maybe it happens after loop or before or inside. Its just something wrong with your C++ code for sure.
Also please refer to Debugging Android NDK native apps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM