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 A24646EC5D; Mon, 5 Apr 2021 12:50:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A24646EC5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617616240; bh=TsXDptHztqgP26zw2GSRZKALM32W6djrQq3XrSHlsR0=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Wy468iymRXjNYNCT2DvlzZJMjoMw1kyr3RJkckDj/W3ncR0RjqatefwTCNKUjxjt9 e/aJ+QvfMbnMIrtacB1O63LI6ALIiuNrig9wj9YfaUwDbayTjE/aBbgue8GYvn4+Sf nGDmVGleyZpZ2FrHGrGYFtrIX6txu+hX33X7aTN4= Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id DB92F6EC5D for ; Mon, 5 Apr 2021 12:50:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DB92F6EC5D Received: by mail-lj1-f181.google.com with SMTP id r20so12133246ljk.4 for ; Mon, 05 Apr 2021 02:50:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=3hjYierFkdw5edW8lKsLYVQ4NF8/0oK6Cfn2DHoG+hc=; b=kW4Bw1KF8GGdwSwB/UZWRBFt5R4I4zjBHLw6Q5uozaD3oTYRNUJc+K5S/KhoS83F2V /wj4MjoGHf24xurlpV/B4RIwb3nb9alfMLW0Ye86xGa4YM7qDhlLu4Z+Y1nxzZYToIjG Iu5O0E3kckAtpytOItkoDEuX6JZaxuRZq0CaKlcNlGP4xuElK6gExLUVP0UqeaWpY1X1 QK+/nLd//uIOEPVhp090qr/J3tWhNM8qCpH1Kv6tYycc7QtlLsdHRHY8tGnoG8x9cycU Wss+TRo5xM1cMDjUn0v+Oh0p51vpOGd/YzTk1CT4CXF3cMb6BGo1YEqM74FxWZpsGFRs HRzg== X-Gm-Message-State: AOAM532OIGgcKy/Z5tlJpGbnfw24pRy6gD6Rz1/uv31jhLTI79Khx4pF yeKCIhUI8rfBQThkyQZtzg+mjEgLxds= X-Google-Smtp-Source: ABdhPJwy4BRUXJ/NTPZA2Qs9LvW5kfMsogbV8Iq8xBOZkSKrjSqdjP/gGAeCJ1jwiQtzKzCakVHHUw== X-Received: by 2002:a05:651c:1189:: with SMTP id w9mr16006052ljo.377.1617616237715; Mon, 05 Apr 2021 02:50:37 -0700 (PDT) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id u9sm1844944ljj.0.2021.04.05.02.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Apr 2021 02:50:36 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id ADE5A5601CD; Mon, 5 Apr 2021 12:50:35 +0300 (MSK) Date: Mon, 5 Apr 2021 12:50:35 +0300 To: Serge Petrenko Message-ID: References: <20210402123420.885834-1-gorcunov@gmail.com> <20210402123420.885834-2-gorcunov@gmail.com> <01f1a611-8eb2-4d82-88f5-0f3912cbf6b0@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01f1a611-8eb2-4d82-88f5-0f3912cbf6b0@tarantool.org> User-Agent: Mutt/2.0.5 (2021-01-21) Subject: Re: [Tarantool-patches] [PATCH v20 1/7] box/schema: make sure hashes are created 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: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: tml , Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Mon, Apr 05, 2021 at 12:28:50PM +0300, Serge Petrenko wrote: > > diff --git a/src/box/schema.cc b/src/box/schema.cc > > index 963278b19..89904e4d2 100644 > > --- a/src/box/schema.cc > > +++ b/src/box/schema.cc > > @@ -372,6 +372,13 @@ schema_init(void) > > funcs = mh_i32ptr_new(); > > funcs_by_name = mh_strnptr_new(); > > sequences = mh_i32ptr_new(); > > + > > + if (spaces == NULL || spaces_by_name == NULL || > > + funcs == NULL || funcs_by_name == NULL || > > + sequences == NULL) { > > + panic("Can't allocate schema hashes"); > > + } > > I've just noticed, all the mh_..._new methods will fail on a null > dereference even before returning. So the check above doesn't > make much sense. This is because our lib/salad/mhash.h is simply buggy and it must be: 1) fixed in mhash level 2) get rid of this macros madness and convert it to normal library. this macros spreading is over the top already and I don't understand why nobody cares about icache footprint Nevertheless we should check for x_new resuls as we do in our other code. Let walk over spaces schema_init spaces = mh_i32ptr_new(); ... sc_space_new space_cache_replace(NULL, space); mh_int_t k = mh_i32ptr_put(spaces, &node_p, ... which is simply nil dereferencing (once we fix bullet 1). > > But I see that some other places have this check > `if (smth = mh_smth_new() == NULL)` and set an error. > > Am I missing something? I think the idea was that mh_x_new doesn't do nil dereference by its own but behaves in a safe way as any library routine should. That said I still think we should check for mh_i32ptr_new results. But won't insist to include this patch, we can drop it if you prefer.