HI, all
My daemon exists a libvirt API call:
virEventRegisterDefaultImpl();
once I called the virEventRegisterDefaultImpl() ,must be core ,the bt stack is:
(gdb) bt
#0 free (ptr=0x1) at include/jemalloc/internal/arena.h:652
#1 0x00007f57690a488a in virFree () from /lib64/libvirt.so.0
#2 0x00007f57690c3562 in virResetError () from /lib64/libvirt.so.0
#3 0x00007f57690c49ad in virEventRegisterDefaultImpl () from /lib64/libvirt.so.0
#4 0x00000000004029ad in main (argc=<optimized out>, argv=<optimized out>) at vnf_mgt/vnf_control.c:2920
(gdb) quit
#0 free (ptr=0x1) at include/jemalloc/internal/arena.h:652
#1 0x00007f57690a488a in virFree () from /lib64/libvirt.so.0
#2 0x00007f57690c3562 in virResetError () from /lib64/libvirt.so.0
#3 0x00007f57690c49ad in virEventRegisterDefaultImpl () from /lib64/libvirt.so.0
#4 0x00000000004029ad in main (argc=<optimized out>, argv=<optimized out>) at vnf_mgt/vnf_control.c:2920
(gdb) quit
the following code copy from libvirt/src/util /
int virEventRegisterDefaultImpl(void)
{
VIR_DEBUG("registering default event implementation");
virResetLastError();
if (virEventPollInit() < 0) {
virDispatchError(NULL);
return -1;
}
virEventRegisterImpl(virEventPollAddHandle,
virEventPollUpdateHandle,
virEventPollRemoveHandle,
virEventPollAddTimeout,
virEventPollUpdateTimeout,
virEventPollRemoveTimeout);
return 0;
}
{
VIR_DEBUG("registering default event implementation");
virResetLastError();
if (virEventPollInit() < 0) {
virDispatchError(NULL);
return -1;
}
virEventRegisterImpl(virEventPollAddHandle,
virEventPollUpdateHandle,
virEventPollRemoveHandle,
virEventPollAddTimeout,
virEventPollUpdateTimeout,
virEventPollRemoveTimeout);
return 0;
}
void
virResetLastError(void)
{
virErrorPtr err = virLastErrorObject();
if (err)
virResetError(err);
}
virResetLastError(void)
{
virErrorPtr err = virLastErrorObject();
if (err)
virResetError(err);
}
static virErrorPtr
virLastErrorObject(void)
{
virErrorPtr err;
err = virThreadLocalGet(&virLastErr);
if (!err) {
if (VIR_ALLOC_QUIET(err) < 0)
return NULL;
if (virThreadLocalSet(&virLastErr, err) < 0)
VIR_FREE(err);
}
return err;
}
virLastErrorObject(void)
{
virErrorPtr err;
err = virThreadLocalGet(&virLastErr);
if (!err) {
if (VIR_ALLOC_QUIET(err) < 0)
return NULL;
if (virThreadLocalSet(&virLastErr, err) < 0)
VIR_FREE(err);
}
return err;
}
void
virResetError(virErrorPtr err)
{
if (err == NULL)
return;
VIR_FREE(err->message);
VIR_FREE(err->str1);
VIR_FREE(err->str2);
VIR_FREE(err->str3);
memset(err, 0, sizeof(virError));
}
virResetError(virErrorPtr err)
{
if (err == NULL)
return;
VIR_FREE(err->message);
VIR_FREE(err->str1);
VIR_FREE(err->str2);
VIR_FREE(err->str3);
memset(err, 0, sizeof(virError));
}
# define VIR_FREE(ptr) virFree(1 ? (void *) &(ptr) : (ptr))
void virFree(void *ptrptr)
{
int save_errno = errno;
free(*(void**)ptrptr);
*(void**)ptrptr = NULL;
errno = save_errno;
}
{
int save_errno = errno;
free(*(void**)ptrptr);
*(void**)ptrptr = NULL;
errno = save_errno;
}
when my daemon link with jemalloc must core,but if i use glibc to manage memory ,then it work fine, why ?