当我尝试malloc并将结构传递给本机库函数时,我的应用程序崩溃了,没有malloc就没有问题,并且如果不调用本机库函数也不会崩溃。请帮助我。
JNIEXPORT void JNICALL Java_com_example_tvgui_List_dataFromJNI(
JNIEnv *env,
jobject instance,jint size, jobjectArray foo) {
DTV_STRUCT1 *data_info;
data_info = (DTV_STRUCT1*)malloc(sizeof(DTV_STRUCT1));
if(data_info == NULL){
__android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG","malloc Failed\n");
return;
}
/*This call causes crash*/
dtv_get_data(0,data_info);
free(data_info);
}
> **ERROR :**android invalid address or address of corrupt block 0x70cb08c8 passed to dlfree 06-28 14:46:19.849
> 6519-6519/com.example.tvgui A/libc: FATAL ERROR occurring at line:
> 4678
> least_addr: 0x31b56000, mchunkptr: 0x70cd5208. Segment Infomation: 06-28 14:46:19.849 6519-6519/com.example.tvgui A/libc: base :
> size 06-28 14:46:19.849 6519-6519/com.example.tvgui A/libc: 000
> 70a41000: 4055040 06-28 14:46:19.849 6519-6519/com.example.tvgui
> A/libc: *** *** *** *** *** *** *** HEAP INFO *** *** *** *** *** ***
> *** 06-28 14:46:19.849 6519-6519/com.example.tvgui A/libc: chunk ptr 0x70cd5208(p), cinuse(0), pinuse(0), chunksize(0) 06-28 14:46:19.849
> 6519-6519/com.example.tvgui A/libc: 70cd5208: 00000000 prev_foot
> 70cd520c: 00000000 head
> 70cd5210: 00000000 fd
> 70cd5214: 00000000 bk 06-28 14:46:19.849 6519-6519/com.example.tvgui A/libc: *** *** *** *** *** *** *** HEAP
> INFO *** *** *** *** *** *** *** 06-28 14:46:19.849
> 6519-6519/com.example.tvgui A/libc: chunk ptr p->fd is invalid with
> any segment 06-28 14:46:19.849 6519-6519/com.example.tvgui A/libc: ***
> *** *** *** *** *** *** HEAP INFO *** *** *** *** *** *** *** 06-28 14:46:19.849 6519-6519/com.example.tvgui A/libc: chunk ptr p->bk is
> invalid with any segment 06-28 14:46:19.849
> 6519-6519/com.example.tvgui A/libc: *** *** *** *** *** *** *** HEAP
> INFO *** *** *** *** *** *** *** 06-28 14:46:19.849
> 6519-6519/com.example.tvgui A/libc: chunk ptr 0x70cd5208(prev),
> cinuse(0), pinuse(0), chunksize(0) 06-28 14:46:19.849
> 6519-6519/com.example.tvgui A/libc: 70cd5208: 00000000 prev_foot
> 70cd520c: 00000000 head
> 70cd5210: 00000000 fd
> 70cd5214: 00000000 bk 06-28 14:46:19.849 6519-6519/com.example.tvgui A/libc: *** *** *** *** *** *** *** HEAP
> INFO *** *** *** *** *** *** *** 06-28 14:46:19.849
> 6519-6519/com.example.tvgui A/libc: chunk ptr "next" is invalid with
> any segment 06-28 14:46:19.849 6519-6519/com.example.tvgui A/libc:
> heap corruption detected by dlmalloc 06-28 14:46:19.849
> 6519-6519/com.example.tvgui A/libc: Fatal signal 6 (SIGABRT) at
> 0x00001977 (code=-6), thread 6519 (m.example.tvgui)