测试()
{
pMsg_node = found_bakup_msg_node();
if(pMsg_node != NULL) {
Dprintf("#%s#%d %p\n", __FUNCTION__, __LINE__, pMsg_node);
ret = cp_msg_node_data(pMsg_node, pMsg_next);
}
}
=============================================== ====================
struct MSG_INFO * found_bakup_msg_node(void) { struct MSG_INFO * msg_node = NULL;
msg_node = (struct MSG_INFO*)malloc(sizeof(struct MSG_INFO));
if(msg_node != NULL) {
memset(msg_node, 0x0, sizeof(struct MSG_INFO));
Dprintf("#%s# %p\n", __FUNCTION__,
msg_node);
}
return msg_node;
}
=============================================== =========
--------------------------- LOG 1 ------------------ --------------
> header=0x923950
>found_bakup_msg_node#alloc_bakup_count=1 0x7f6090032f70 //return from malloc()
>cp_msg_list#561
> cp_msg_node_data#458
>cp_msg_node_data#463 0xffffffff90032f70 0x923950 //notice here
>Segmentation fault
> robin@robin-desktop:/media/work/project/rcd$
-------------------------- LOG 2 ------------------- -------------
#cp_msg_list#566
#found_bakup_msg_node#alloc_bakup_count=180 **0x7fe6e000d5b0**
#cp_msg_node_data#464 **0xffffffffe000d5b0** 0x2154620
Segmentation fault
robin@robin-desktop:/media/work/project/rcd$
答案 0 :(得分:0)
你试过在gdb下运行程序吗?它通常会显示您遇到分段错误的原因,并且通常可以了解如何使用gdb。