Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jIwes-00052i-0z for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Mar 2020 15:49:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jIweo-0004et-MT for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Mar 2020 15:48:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jIweo-0004cM-Fv for pgsql-bugs@lists.postgresql.org; Mon, 30 Mar 2020 15:48:58 +0000 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jIwem-00070h-1i for pgsql-bugs@lists.postgresql.org; Mon, 30 Mar 2020 15:48:57 +0000 Received: by mail-qk1-x741.google.com with SMTP id v7so19492753qkc.0 for ; Mon, 30 Mar 2020 08:48:55 -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=4Q4waUIDc8w/C6eSg2Q57Sgek74w0TgrdERKaELlw6Q=; b=dKZ7SkjXNgnHltGybMvoaFgoY3u4dgqIOrOjqUBfNKOz+ByzBBJNIMo0TGQfYm/VM/ 7ctlaAeuWPxe5POeS/6faa7zBBt6+eXYpwWEz7VeCoAy6mc3+EVvqHSsb3AklNlwQ3hE n3xaw3+HQGv0AcgMkNvzp4WwXpCrkqEAK5kDAZzYUcJ4qVXxdUNvnwZ+dLTJYrjbIsap PEACTdkWL6Foq014CmhV7baylJKIY/J7cSSxf2PQLEbdj47jmcB6fS1WImP72r+aESre nWAPUIxvFDr6ePPK83+R8eMUfIteTD+mTK/dqPj8axePYluShDllKUlnA5IwYsJMkBK6 fq2g== 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=4Q4waUIDc8w/C6eSg2Q57Sgek74w0TgrdERKaELlw6Q=; b=ug7a72B8dX0MAZUGMQKtMSWzCH0EqDvFw+TuvPQBs+VQ2AjK3kmLTl6+VcNewIGq+k hjXKBN1E63qdSx1nK9LezO+LGV/03DU7ds4KOPk6btcG9xIwa88ZEMC9McS5MHtvKT02 /lXeLnxOVhnqiAecd4+Y/t0WFLlL4rVP4PBnp+d63zGUsqFR2H6oXRCkNb475ZaynV9z ss8ftMmFTBrGKGTlquOSXu/UJBRbfCMgNL1z5lpezbNGbiqoDFO8YpeBZrPTHv7agh2E Wn7mf9DM4ZmK1zzY0BoUJO1zjNPJ9jsd3HtxI3s8ulUNQ1Msbq5QYE3ffrVss7dO+13w Pr9w== X-Gm-Message-State: ANhLgQ1mJL16IVWRnSeCh8bxrV/a+zbC9jn+tKaCm6SAYv7f7HK+OqeY DuDEi0we7xxWeZK6qMSHB0y06w== X-Google-Smtp-Source: ADFU+vuuVs0pZa+Al99ELY9vic9x0ZaYsJzENOQKgNYYcBVfFAfbJWu0bbuBCbRfNOX2E8IgaPC66Q== X-Received: by 2002:a37:86c4:: with SMTP id i187mr646420qkd.110.1585583335042; Mon, 30 Mar 2020 08:48:55 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id z11sm11202420qti.23.2020.03.30.08.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 08:48:54 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 7103E300A04; Mon, 30 Mar 2020 12:48:51 -0300 (-03) Date: Mon, 30 Mar 2020 12:48:51 -0300 From: Alvaro Herrera To: Tom Lane Cc: Michael Paquier , hghwng@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16330: psql accesses null pointer in connect.c:do_connect Message-ID: <20200330154851.GA15986@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <17009.1585582541@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Mar-30, Tom Lane wrote: > Michael Paquier writes: > > On Mon, Mar 30, 2020 at 02:20:48AM +0000, PG Bug reporting form wrote: > >> If the connection to postmaster is closed, then trying to re-connect to > >> another one leads to SIGSEGV. > > > A fix like the attached should be sufficient as if we know that > > PQhost() is NULL for the old connection we cannot use the old > > hostaddr. Alvaro, what do you think? > > It looks to me like there's a similar hazard a bit further down > (line 3029): > > appendConnStrVal(&connstr, PQdb(o_conn)); > > I wonder if we should force reuse_previous to false if there's > no o_conn, rather than fixing this stuff piecemeal. That was my impression too. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services