From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 64B126FC8E; Mon, 26 Apr 2021 23:58:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 64B126FC8E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1619470701; bh=Mh6bwCh0XwmwbgixGFpd4PlILPotxKsjc+Q3cvytCQM=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ya5BAUdY0ePfJI7PEbe4HynbZBV69K/5/NUQJnZJ1UeQzkjQoYf77ZYba4iL4Anx1 32uQ5qY60FOiGTLSqQMi1/jlYlKIExh9k/X2MTRyOIYUMW1yWJdlbNhhP9XH8Dw7Df hZqKrF/lLB6kp+bOgzZgbm4pbOAoNX2Njxv3TrZo= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 8BDD36FC8E for ; Mon, 26 Apr 2021 23:58:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8BDD36FC8E Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lb8J7-0006av-3x; Mon, 26 Apr 2021 23:58:17 +0300 To: Cyrill Gorcunov , tml References: <20210426101000.278874-1-gorcunov@gmail.com> <20210426101000.278874-3-gorcunov@gmail.com> Message-ID: <172de876-2f6c-b43f-2c0a-59697c6c82aa@tarantool.org> Date: Mon, 26 Apr 2021 22:58:16 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210426101000.278874-3-gorcunov@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9ECFD8CE5F059401062EF72DCC8B8CDABD8D4F98D4AE0C03D182A05F53808504070D4A2589D041595D00E7E07283AD497ACF122D333408CEEE6C6E5F6ACBD9482 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7ECD3FEFFF0C7120DC2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE70C5E0F71D77D667BEA1F7E6F0F101C67CDEEF6D7F21E0D1D9295C2E9FA3191EE1B59CA4C82EFA6586C36FC644FDF57ABDC59AA2B40EF1988F6B57BC7E64490618DEB871D839B73339E8FC8737B5C22494854413538E1713FCC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C0A29E2F051442AF778941B15DA834481F9449624AB7ADAF372E808ACE2090B5E14AD6D5ED66289B5259CC434672EE63711DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C369456C5265B6C55C35872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C978315B9C9F64DDC703D899D32A3E8D98C3BE X-C1DE0DAB: 0D63561A33F958A535508C17716700D8E49F95CE2BA5AEF0EE19D2E7C7E89424D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3475FE4AA98865E235E881A7E7468057473F72963B6DA006DDC58FF46459F935FDA8C196290AF6F3E81D7E09C32AA3244CDD160BDEC8EC8BE14C8AAAB14DFB414AF26BFA4C8A6946B8927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojmUj/IHfqgKcPAFUk9t8yzA== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822A37D3A111E924958A3B4841EF2D3721E3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 2/2] fiber: fiber_join -- don't crash on misuse X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the patch! > diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c > index baf78a130..dd7498dd7 100644 > --- a/src/lib/core/fiber.c > +++ b/src/lib/core/fiber.c > @@ -615,7 +615,10 @@ fiber_join(struct fiber *fiber) > int > fiber_join_timeout(struct fiber *fiber, double timeout) > { > - assert(fiber->flags & FIBER_IS_JOINABLE); > + if (!(fiber->flags & FIBER_IS_JOINABLE)) { 1. https://github.com/tarantool/tarantool/wiki/Code-review-procedure#code-style In C we don't apply ! operator to non-boolean values. It means, to check if an integer is not 0, you use != 0. To check if a pointer is not NULL, you use != NULL. The same for ==; > + diag_set(IllegalParams, "the fiber is not joinable"); > + return -1; > + } > > if (! fiber_is_dead(fiber)) { > bool exceeded = false; > diff --git a/test/unit/fiber.cc b/test/unit/fiber.cc > index 9c1a23bdd..fbdd82772 100644 > --- a/test/unit/fiber.cc > +++ b/test/unit/fiber.cc > @@ -96,6 +96,9 @@ fiber_join_test() > header(); > > struct fiber *fiber = fiber_new_xc("join", noop_f); > + /* gh-6046: crash on attempt to join non joinable */ > + fiber_set_joinable(fiber, false); > + fiber_join(fiber); 2. Would be good to test that it returns -1, and that the diag is not empty.