lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I use luv[1] (just modify some code for upgrade to lua5.2) and write pure lua program on Freebsd but the program core dump sometime, I have posted my question at libuv's newsgroup [2] and the answer say there maybe luv's bug.

at luv_object.c

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.

[1] https://github.com/richardhundt/luv
[2] https://groups.google.com/forum/#!topic/libuv/L0Q28CRDYiE