Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iX6y0-000164-VD for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2019 17:07:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iX6xx-0001Rr-RI for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2019 17:07:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iX6xx-0001Rk-EF for pgsql-hackers@lists.postgresql.org; Tue, 19 Nov 2019 17:07:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iX6xt-000773-Ki for pgsql-hackers@postgresql.org; Tue, 19 Nov 2019 17:06:59 +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 xAJH6oO2019335; Tue, 19 Nov 2019 12:06:50 -0500 From: Tom Lane To: Andres Freund cc: vignesh C , Pg Hackers Subject: Re: initdb SegFault In-reply-to: <20191119161059.6styj2huulh4zrkw@alap3.anarazel.de> References: <7379.1574176562@sss.pgh.pa.us> <20191119161059.6styj2huulh4zrkw@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 19 Nov 2019 08:10:59 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19333.1574183210.1@sss.pgh.pa.us> Date: Tue, 19 Nov 2019 12:06:50 -0500 Message-ID: <19334.1574183210@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > Agreed wrt this specific failure scenario. It does however seem not > great that callsites for PQExpBuffer ought to check every call for > allocation failures, in the general case. It is possible to check just once at the end, using the PQExpBufferBroken API, and I believe that libpq for instance is fairly careful about that. I agree that programs that just need to print something and exit could perhaps ask pqexpbuffer.c to handle that for them. (But initdb still doesn't fall in that category, because of its very nontrivial atexit handler :-(.) > I wonder if, for frontend paths, a simplified error handling path would > be worthwhile for OOM paths. Doing only a write() or such to print an > error message. Perhaps. You wouldn't get any translation --- but then, gettext is probably going to fail anyway under such conditions. regards, tom lane