I use malloc() to request an <ubus_request> structure, and then call ubus_invoke_async() to communicate with other processes.
But sometimes my program occur segment fault.
Here are my send code:
static int ubus_async_request(UBUS_REQ_CTX* req_ctx)
{
......
struct ubus_request *req=(struct ubus_request *)calloc(1,sizeof(struct ubus_request));
ret = ubus_lookup_id(&(ubus_conn.ctx), req_ctx->obj_name, &obj_id);
ret=ubus_invoke_async(&(ubus_conn.ctx), obj_id, req_ctx->method, msg, req);
req->data_cb = ubus_async_request_data_cb;
req->complete_cb = ubus_async_request_complete_cb;
req->priv = req_ctx;
ubus_complete_request_async(&(ubus_conn.ctx), req);
return ret;
}
The segfault occurs at ubus_process_req_data()->__ubus_process_req_data()->_list_del()
I printed the information about req->pending as follows:
req->pending=0x7ff7f57c50
req->pending.next=0x8000007ff7f57c50
req->pending.prev=0x7ff7f57c51
Under normal circumstances,req->pending 、req->pending.next 、req->pending.prev should be equal
But now they have some strange values?