libpomelo2 icon indicating copy to clipboard operation
libpomelo2 copied to clipboard

pc_client_cleanup() inside pc_client_poll() bug.

Open xpol opened this issue 8 years ago • 1 comments

If pc_client_cleanup() called inside pc_client_poll() will trigger assertion faild:

#3  0x00007fff840ecdf8 in __assert_rtn ()
#4  0x0000000101879cd7 in pc_mutex_destroy at deps/libpomelo2/src/pc_mutex.h:82
#5  0x0000000101879c11 in pc_client_cleanup at deps/libpomelo2/src/pc_pomelo.c:291
#6  0x00000001018abb72 in Client_gc(lua_State*) at lua-pomelo.cpp:465
#7  0x00000001017e8f28 in lj_BC_FUNCC ()
#8  0x00000001017eb366 in gc_finalize ()
#9  0x00000001017eb8ed in gc_onestep ()
#10 0x00000001017ebd48 in lj_gc_fullgc ()
#11 0x00000001017f9635 in lua_gc ()
#12 0x0000000101840ec7 in lj_cf_collectgarbage ()
#13 0x00000001017e8f28 in lj_BC_FUNCC ()
#14 0x00000001017f91f4 in lua_pcall ()
#15 0x00000001018abfc3 in lua_request_cb(pc_request_s const*, int, char const*) at lua-pomelo.cpp:559
#16 0x000000010187c560 in pc__trans_resp at deps/libpomelo2/src/pc_trans.c:333
#17 0x0000000101879dbc in pc__handle_event at deps/libpomelo2/src/pc_pomelo.c:310
#18 0x0000000101879447 in pc_client_poll at deps/libpomelo2/src/pc_pomelo.c:374

the pc_client_poll locks the event_mutex and pc_client_cleanup tries to destroy it.

The library neither checking polling states in pc_client_cleanup nor provide way to delay destroy client.

xpol avatar Apr 06 '16 03:04 xpol

we should ensure pc_client_cleanup() never be called in polling callbacks, so do async callbacks

cynron avatar Apr 25 '16 09:04 cynron