From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id EECD130667 for ; Thu, 6 Dec 2018 07:25:50 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rsv_LmO1cA-J for ; Thu, 6 Dec 2018 07:25:50 -0500 (EST) 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 turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 88D0F305CF for ; Thu, 6 Dec 2018 07:25:50 -0500 (EST) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v6 1/1] box: fix checkpoint_delete Date: Thu, 6 Dec 2018 15:25:46 +0300 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org Cc: Kirill Shcherbatov http://github.com/tarantool/tarantool/tree/kshch/gh-3858-fix-checkpoint-delete https://github.com/tarantool/tarantool/issues/3858 The rlist_foreach_entry iterator was used for freeing resources. As a result there was dirty access to memory during next step of for-loop. Replaced with rlist_foreach_entry_safe valid for destructors. Closes #3858 --- src/box/memtx_engine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c index 9e05ecf63..5cf70ab94 100644 --- a/src/box/memtx_engine.c +++ b/src/box/memtx_engine.c @@ -610,8 +610,8 @@ checkpoint_new(const char *snap_dirname, uint64_t snap_io_rate_limit) static void checkpoint_delete(struct checkpoint *ckpt) { - struct checkpoint_entry *entry; - rlist_foreach_entry(entry, &ckpt->entries, link) { + struct checkpoint_entry *entry, *tmp; + rlist_foreach_entry_safe(entry, &ckpt->entries, link, tmp) { entry->iterator->free(entry->iterator); free(entry); } -- 2.19.2