Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dFpUg-00040Z-CK for pgsql-bugs@arkaria.postgresql.org; Tue, 30 May 2017 22:20:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dFpUf-0003ih-S0 for pgsql-bugs@arkaria.postgresql.org; Tue, 30 May 2017 22:20:01 +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 1dFpUf-0003iA-6w for pgsql-bugs@postgresql.org; Tue, 30 May 2017 22:20:01 +0000 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dFpUc-0004Go-HA for pgsql-bugs@postgresql.org; Tue, 30 May 2017 22:20:00 +0000 Received: by mail-qk0-x22c.google.com with SMTP id y201so80300191qka.0 for ; Tue, 30 May 2017 15:19:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=kQxUQeyRgfbWh14IPBzQU4l4TFPPhIgQhJdqHXKVkX0=; b=nxHbnaPCZG8rY8SVegwlRS+SR4URYAI6ToHv5eiQC6WCYQ2JuMNXEUdvs4bdUtvA83 xI1OqJTwJm/B0XC/YaGMU4iGWTi1X7ah5CzLcmQGMYiAXX9ClZC2X0eGhJzaj9Myyhgf OfABGaGONuENM/Hl8ykIpysUZiHDgOeAdkIhsqJ2zTgeK6P6cuOlzjFrn63Nh6Y41jAh v8UBwrJLEwftgkXsfGcNLXc7BH3vcc6Ms3XOtUNu0B9ziHAktA0fpabUInM1T2Lcu84a 4YGUWeXPDiBAnpBuj5R6O5mGXpArgKaE4PMrEZoS2GnakWFxZpv7JMqn9CXS8o2J2Ix1 Z72g== 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:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=kQxUQeyRgfbWh14IPBzQU4l4TFPPhIgQhJdqHXKVkX0=; b=NMmYCiLMV/rhb+J5F95AbcNG1XVSvKIELOw8zR5fFveu6TU5o+Wy+opgR+J+bCcJ7D ijSg4HoypWX2pMbDCXimSeTJMdFgF0iCCAf1eHhHlWRbZRkbSqtq+hP7y0mIzZmmRGnw unnr/d32yMer1ckA9RGfM/K71S6pzQZhncCQFkplIkcexH4BqbAHq9DD7R+WgCJiooV4 3dizqQZ6HfpGTgSRzVjSgZ75uzulPmhxslz4b/VzE1z7a1wbfFuRLrl9U9lEDb7Rpe0y qNh/vHW0PUEasGBOFIakhI+QEh2ybCgpdnUnMWmUq0kiC48GYv5GKcgrHVpG0ZFqySSi S9dQ== X-Gm-Message-State: AODbwcAT1bUtZbe+XrVGWZxStLEpc//coIliEqUCndjRDa4cCDxfkOtV +maazrkOBIhopGRj X-Received: by 10.55.10.12 with SMTP id 12mr14168060qkk.217.1496182797427; Tue, 30 May 2017 15:19:57 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([179.57.115.10]) by smtp.gmail.com with ESMTPSA id l70sm5561741qki.6.2017.05.30.15.19.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 15:19:57 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 32F1F39A; Tue, 30 May 2017 18:19:55 -0400 (-04) Date: Tue, 30 May 2017 18:19:55 -0400 From: Alvaro Herrera To: Thomas Munro Cc: digoal@126.com, PostgreSQL Bugs Subject: Re: BUG #14668: BRIN open autosummarize=on , database will crash Message-ID: <20170530221955.cdldd7bz77neabi5@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Thomas Munro wrote: > I guess brin_free_tuple(lastPageTuple) should only be called if it's > not NULL, so I guess brin.c lacks an "else" here: > > - brin_free_tuple(lastPageTuple); > + else > + brin_free_tuple(lastPageTuple); > > It doesn't crash for me with that change. Pushed fix. Actually that's not correct either, because tuples returned by brinGetTupleForHeapBlock are not supposed to be freed at all since they are shared buffer items. The correct thing to do there was to release the buffer lock ... Thanks for the report and analysis. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs