void luvL_object_close_cb(uv_handle_t* handle) {
luv_object_t* self = container_of(handle, luv_object_t, h);
self->flags |= LUV_OCLOSED;
self->state = NULL;
luvL_cond_signal(&self->rouse);
}
void luvL_object_close(luv_object_t* self) {
if (!luvL_object_is_closing(self)) {
self->flags |= LUV_OCLOSING;
uv_close(&self->h.handle, luvL_object_close_cb);
}
}
The luvobject do not have 'close' meth and luvL_object_close only be called at lua's __gc, so the self->h.handle pass to uv_close will be invalid, and also the callback handle invalid too.
The bug looks very obvious but the core dump can not easily reproduce.
I think write 'close' meth insteadof __gc is a way, more advise, please.