From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 2235545C305 for ; Fri, 5 Jun 2020 02:43:28 +0300 (MSK) From: Vladislav Shpilevoy Date: Fri, 5 Jun 2020 01:43:13 +0200 Message-Id: <4cdd34e07cbded81821b4a3c7c2c3db506983993.1591313754.git.v.shpilevoy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 06/11] swim: fix zero division List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, tsafin@tarantool.org, alyapunov@tarantool.org If swim_cfg() fails during first configuration after the self member is created, it is deleted before return. Deletion of the member causes member update event addition to the dissemination queue. The event TTL depends on log2(member count), where the count is zero in the described situation. This leads to zero division according to clang sanitizer. The patch makes member deletion from the member table happen a little later, so the member event registration can't ever see the table empty. Part of #4609 --- src/lib/swim/swim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index 9a7b4ce85..396bd7c45 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -874,11 +874,6 @@ swim_delete_member(struct swim *swim, struct swim_member *member) { say_verbose("SWIM %d: member %s is deleted", swim_fd(swim), tt_uuid_str(&member->uuid)); - struct mh_swim_table_key key = {member->hash, &member->uuid}; - mh_int_t rc = mh_swim_table_find(swim->members, key, NULL); - assert(rc != mh_end(swim->members)); - mh_swim_table_del(swim->members, rc, NULL); - rlist_del_entry(member, in_round_queue); /* Failure detection component. */ if (! heap_node_is_stray(&member->in_wait_ack_heap)) @@ -888,6 +883,11 @@ swim_delete_member(struct swim *swim, struct swim_member *member) swim_on_member_update(swim, member, SWIM_EV_DROP); rlist_del_entry(member, in_dissemination_queue); + struct mh_swim_table_key key = {member->hash, &member->uuid}; + mh_int_t rc = mh_swim_table_find(swim->members, key, NULL); + assert(rc != mh_end(swim->members)); + mh_swim_table_del(swim->members, rc, NULL); + rlist_del_entry(member, in_round_queue); swim_member_delete(member); } -- 2.21.1 (Apple Git-122.3)