Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c8Aaw-0000uN-U0 for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Nov 2016 18:42:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1c8Aaw-0003kE-7v for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Nov 2016 18:42:34 +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 1c8AZW-0002Bf-Tv for pgsql-hackers@postgresql.org; Sat, 19 Nov 2016 18:41:07 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1c8AZQ-0000nO-Dl for pgsql-hackers@postgresql.org; Sat, 19 Nov 2016 18:41:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id uAJIer3o005484; Sat, 19 Nov 2016 13:40:53 -0500 From: Tom Lane To: Michael Paquier cc: Andreas Seltenreich , PostgreSQL mailing lists Subject: Re: [sqlsmith] Crash on GUC serialization In-reply-to: References: <871sy78wno.fsf@credativ.de> <2655.1479576672@sss.pgh.pa.us> Comments: In-reply-to Michael Paquier message dated "Sat, 19 Nov 2016 09:44:23 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5482.1479580853.1@sss.pgh.pa.us> Date: Sat, 19 Nov 2016 13:40:53 -0500 Message-ID: <5483.1479580853@sss.pgh.pa.us> X-Pg-Spam-Score: -4.8 (----) 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 Michael Paquier writes: > On Sat, Nov 19, 2016 at 9:31 AM, Tom Lane wrote: >> Thanks for the report! Looks like the serialization code has overlooked >> the fact that string-valued GUCs can be NULL. Surprising we didn't >> find that before ... > I was half-way through it when you sent your email. It seems to me > that we need to take care only of the case for PGC_STRING, per the > attached. Meh; that might be stopping the crash for you but you didn't consider what to do in serialize_variable. Some machines would dump core there instead, and others would print "(null)" which wouldn't fit in the allocated space. The bigger problem here is that set_config_option cannot be used to set a string GUC's value to NULL --- it will treat value == NULL as a request to set to the reset_val. The best we can do is to convert the value into an empty string, which isn't quite the same thing, though it may be close enough (compare e45e990e4). I'm also pretty unexcited about serializing float variables this way --- assuming that sprintf("%.17g") will reconstruct doubles exactly is just asking for trouble IMO. So I can't escape the itchy feeling that this entire chunk of code needs to be thrown away and rewritten differently. But it'd take some refactoring of the code under set_config_option to do it nicely, which is more work than we probably want to put in now. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers