PROTON-1842: timer rearm outside lock can try to access freed memory if another thread ends the pconnection ahead of the rearm
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0a5c18a1 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0a5c18a1 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0a5c18a1 Branch: refs/heads/go1 Commit: 0a5c18a1034deaa76deb9367d068e80c2726aa7c Parents: 1e1fd02 Author: Clifford Jansen <cliffjan...@apache.org> Authored: Mon May 7 23:12:11 2018 -0700 Committer: Clifford Jansen <cliffjan...@apache.org> Committed: Mon May 7 23:12:11 2018 -0700 ---------------------------------------------------------------------- c/src/proactor/epoll.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0a5c18a1/c/src/proactor/epoll.c ---------------------------------------------------------------------- diff --git a/c/src/proactor/epoll.c b/c/src/proactor/epoll.c index 752e6e0..f77fca9 100644 --- a/c/src/proactor/epoll.c +++ b/c/src/proactor/epoll.c @@ -1179,19 +1179,15 @@ static pn_event_batch_t *pconnection_process(pconnection_t *pc, uint32_t events, return NULL; } } - bool rearm_pc = pconnection_rearm_check(pc); if (!pc->timer_armed && !pc->timer.shutting_down && pc->timer.timerfd >= 0) { - pc->timer_armed = true; // about to rearm outside the lock - rearm_timer = true; // so we remember - } - unlock(&pc->context.mutex); - - if (rearm_timer) { + pc->timer_armed = true; rearm(pc->psocket.proactor, &pc->timer.epoll_io); } - if (rearm_pc) pconnection_rearm(pc); + bool rearm_pc = pconnection_rearm_check(pc); // holds rearm_mutex until pconnection_rearm() below + unlock(&pc->context.mutex); + if (rearm_pc) pconnection_rearm(pc); return NULL; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org