Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjHiD-0005yW-OS for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Mar 2017 03:47:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cjHiD-00011N-B6 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Mar 2017 03:47:29 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cjHiB-0000yt-Bi for pgsql-hackers@postgresql.org; Thu, 02 Mar 2017 03:47:27 +0000 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cjHi8-0003JK-NA for pgsql-hackers@postgresql.org; Thu, 02 Mar 2017 03:47:25 +0000 Received: by mail-wm0-x229.google.com with SMTP id v186so125187463wmd.0 for ; Wed, 01 Mar 2017 19:47:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=KUvpiEQLFlwxfXwg9p8qCWbn9UNhfSfYDlZLNyHeb5o=; b=usZJzdIKfZTlfRCjKY0rau74zWVlIbVwcLWHwbDKYuiZZaZkUntlybJ6z1Pw1qJORP ZDCmypIYX3xHULwEd/RXcJBnfUCaR4/R6C/tydHkqYb2vPXDvfncwfngys0SHFZGKFqF FdMHTMpOSCbQ0m0GkPLb6siGKoF2bDIL10qtVaTq0WC4UlgcMx4T+20AoJ2QjVwm1rhH dX2QtT6HTUXgbWntfrWb5k3/6c7IKuPDSS41hKwSrMrX6sFwP9hnjQi4cVcPS6Iphr0S 48o2X7N1QZjr0LkZKh8OSqZ543IExypWH5KKBdisLvMRUmfR2a+oiDsxR0sO2YA6yDRZ 1rMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=KUvpiEQLFlwxfXwg9p8qCWbn9UNhfSfYDlZLNyHeb5o=; b=rvapLsTfGbewWUzpZ/FxQtvMo9toQhbjO1YuLrZqnp8bd4KzfE9//NOZz5DlAW+LfW SDqs4UdepcZNdN4WG5msqnPBbJpgIzQ07ASyEjxDY/J/Hnb3Jc9Ep1ilmQ9vsd646vsT n78iT8qRvEN0RBwZl7616qVTI5tGV4bIa4LGR+aTSYq8D/xEqlJOb0r8Oj3zryqRjnzz IoeROFQtiVrTxA6hjf6mHRFlHr/w5vh9bDyztFd+hhORN8nqWLfu/tob6NHlbTpzNkaV VZECs0QHpF/ceQ9B7Xh4mJKAHSEPGu0BSkuYiyuO+NnFwo1Czc6Mw+z6/6+/HwalEg5P Gh+w== X-Gm-Message-State: AMke39lWLcbFxcdB9X7bI3wv4LrAWRXV806LvflJf/RkC1rxhiZ9qiLbHrUPcuzj8JmVmF0Z5wrWRGD7VQucUedmxvEcuQnHp6lo2igpUsVaWUMVrnWYltiPiqeqQ66IJotgmyyXMkrFnLKg0G/Hwzb0H5v8rMMZmIOhIfcZ0EH51M0IKn1/iveSGqTWZSW7M0PPRoDwPxM3 X-Received: by 10.28.86.214 with SMTP id k205mr5654050wmb.26.1488426441849; Wed, 01 Mar 2017 19:47:21 -0800 (PST) Received: from [10.137.2.17] (ip-89-177-46-65.net.upcbroadband.cz. [89.177.46.65]) by smtp.gmail.com with ESMTPSA id e6sm9040543wrc.30.2017.03.01.19.47.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2017 19:47:21 -0800 (PST) Subject: Re: PATCH: two slab-like memory allocators To: Andres Freund , Tom Lane References: <20170227174201.yrofai7neyp6shb2@alap3.anarazel.de> <20170228034232.4h7ouyhxq4lbbao2@alap3.anarazel.de> <1240.1488254244@sss.pgh.pa.us> <20170228051630.3qcevakcaaa6b4ef@alap3.anarazel.de> <1671.1488259784@sss.pgh.pa.us> <20170228074420.aazv4iw6k562mnxg@alap3.anarazel.de> <20170228184122.extbigaer5ryrt3z@alap3.anarazel.de> <20170301041835.wli3viwnxr5wonfv@alap3.anarazel.de> <20170301042936.usv23f4iaumeyptf@alap3.anarazel.de> <20170301225545.eoevemua234g4fzq@alap3.anarazel.de> Cc: Petr Jelinek , Petr Jelinek , Robert Haas , John Gorman , pgsql-hackers From: Tomas Vondra Message-ID: Date: Thu, 2 Mar 2017 04:47:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170301225545.eoevemua234g4fzq@alap3.anarazel.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 03/01/2017 11:55 PM, Andres Freund wrote: > On 2017-02-28 20:29:36 -0800, Andres Freund wrote: >> On 2017-02-28 20:18:35 -0800, Andres Freund wrote: >>> - Andres, hoping the buildfarm turns greener >> >> Oh well, that didn't work. Investigating. > > The fix for that was fairly trivial, and the buildfarm has cooled down. > > The issue was that on 32bit platforms the Datum returned by some > functions (int2int4_sum in this case) isn't actually a separately > allocated Datum, but rather just something embedded in a larger > struct. That, combined with the following code: > if (!peraggstate->resulttypeByVal && !*isnull && > !MemoryContextContains(CurrentMemoryContext, > DatumGetPointer(*result))) > seems somewhat problematic to me. MemoryContextContains() can give > false positives when used on memory that's not a distinctly allocated > chunk, and if so, we violate memory lifetime rules. It's quite > unlikely, given the required bit patterns, but nonetheless it's making > me somewhat uncomfortable. > I assume you're only using that code snippet as an example of code that might be broken by MemoryContextContains() false positives, right? (I don't see how the slab allocator could interfere with aggregates, as it's only used for reorderbuffer.c). > > Do others think this isn't an issue and we can just live with it? > My understanding is all the places calling MemoryContextContains() assume they can't receive memory not allocated as a simple chunk by palloc(). If that's not the case, it's likely broken. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers